fixing
This commit is contained in:
parent
99e5baeefb
commit
09a819dcf1
|
|
@ -70,7 +70,15 @@ export const useServerRouter = <T extends ReturnType<typeof newServerRouter>>(
|
|||
}
|
||||
|
||||
return {
|
||||
async handle(arg: ServerContext | SessionContext<any>) {
|
||||
async handle(
|
||||
arg: ServerContext | SessionContext<any>,
|
||||
opt?: {
|
||||
rewrite?: (arg: {
|
||||
body: Bun.BodyInit;
|
||||
headers?: Record<string, string>;
|
||||
}) => Bun.BodyInit;
|
||||
}
|
||||
) {
|
||||
const { url, req, handle } = arg;
|
||||
const found = findRoute(rou, undefined, url.pathname);
|
||||
if (found) {
|
||||
|
|
@ -101,7 +109,7 @@ export const useServerRouter = <T extends ReturnType<typeof newServerRouter>>(
|
|||
|
||||
return new Response(JSON.stringify(result));
|
||||
}
|
||||
return handle(req);
|
||||
return handle(req, opt);
|
||||
},
|
||||
};
|
||||
};
|
||||
|
|
|
|||
|
|
@ -9,7 +9,10 @@ export type SessionServerHandler = {
|
|||
handle: (
|
||||
arg: ServerContext,
|
||||
opt?: {
|
||||
rewrite?: (arg: { body: Bun.BodyInit; headers: Headers }) => Bun.BodyInit;
|
||||
rewrite?: (arg: {
|
||||
body: Bun.BodyInit;
|
||||
headers?: Record<string, string>;
|
||||
}) => Bun.BodyInit;
|
||||
}
|
||||
) => Promise<Response>;
|
||||
};
|
||||
|
|
@ -39,12 +42,12 @@ export const initSessionServer = <T>(
|
|||
};
|
||||
|
||||
if (url.pathname.startsWith("/_session/")) {
|
||||
const res = await session_router.handle(route_arg);
|
||||
const res = await session_router.handle(route_arg, opt);
|
||||
if (res) return res;
|
||||
}
|
||||
|
||||
if (arg.router) {
|
||||
const res = await arg.router.handle(route_arg);
|
||||
const res = await arg.router.handle(route_arg, opt);
|
||||
if (res) return res;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -76,7 +76,7 @@ export type ServerContext = {
|
|||
opt?: {
|
||||
rewrite?: (arg: {
|
||||
body: Bun.BodyInit;
|
||||
headers: Response["headers"];
|
||||
headers?: Record<string, string>;
|
||||
}) => Bun.BodyInit;
|
||||
}
|
||||
) => Promise<Response>;
|
||||
|
|
|
|||
Loading…
Reference in New Issue