package org.openautonomousconnection.webserver.api;

import org.openautonomousconnection.protocol.packets.v1_0_0.beta.WebRequestPacket;
import org.openautonomousconnection.protocol.side.web.ConnectedWebClient;
import org.openautonomousconnection.protocol.side.web.ProtocolWebServer;

/**
 * Context passed to Java WebPages (client, request, session).
 */
public final class WebPageContext {

    public final ConnectedWebClient client;
    public final WebRequestPacket request;
    public final SessionContext session;

    public WebPageContext(ConnectedWebClient client, ProtocolWebServer server, WebRequestPacket request) throws Exception {
        this.client = client;
        this.request = request;
        this.session = SessionContext.from(client, server, request.getHeaders());
    }
}
