This commit is contained in:
Rizky 2024-12-11 04:41:04 +00:00
parent 59495ee186
commit c0e612e6f6
2 changed files with 7 additions and 4 deletions

View File

@ -8,7 +8,10 @@ import { ServerContext } from "./type";
type WS = ServerWebSocket<{ url: string }>;
type SessionServerHandler = {
cleanup: () => Promise<void>;
handle: (arg: ServerContext) => Promise<Response>;
handle: (
arg: ServerContext,
opt?: { cache_accept?: string }
) => Promise<Response>;
};
export const initSessionServer = <T>(
@ -24,7 +27,7 @@ export const initSessionServer = <T>(
const server_handler: SessionServerHandler = {
async cleanup() {},
async handle(server_arg) {
async handle(server_arg, opt) {
const { req, handle, url } = server_arg;
const route_arg = {
@ -45,7 +48,7 @@ export const initSessionServer = <T>(
if (res) return res;
}
return handle(req);
return handle(req, opt);
},
};

View File

@ -71,7 +71,7 @@ export interface SessionContext<T> extends ServerContext {
export type ServerContext = {
req: Request;
server: Server;
handle: (req: Request) => Promise<Response>;
handle: (req: Request, opt?: { cache_accept?: string }) => Promise<Response>;
mode: "dev" | "prod";
url: {
raw: URL;