package org.openautonomousconnection.webserver.api;

import org.openautonomousconnection.protocol.packets.v1_0_0.beta.web.WebRequestPacket;
import org.openautonomousconnection.protocol.side.server.CustomConnectedClient;
import org.openautonomousconnection.protocol.side.web.ProtocolWebServer;
import org.openautonomousconnection.webserver.utils.WebHasher;
import org.openautonomousconnection.webserver.utils.RequestParams;

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

    public final CustomConnectedClient client;
    public final WebRequestPacket request;
    public final SessionContext session;
    public final RequestParams params;
    public final WebHasher hasher;

    public WebPageContext(
            CustomConnectedClient client,
            ProtocolWebServer server,
            WebRequestPacket request,
            RequestParams params,
            WebHasher hasher
    ) throws Exception {
        this.client = client;
        this.request = request;
        this.session = SessionContext.from(client, server, request.getHeaders());
        this.params = params;
        this.hasher = hasher;
    }
}
