diff --git a/fixtures/rpc-sanity/src/index.ts b/fixtures/rpc-sanity/src/index.ts index 183dea9..aac7050 100644 --- a/fixtures/rpc-sanity/src/index.ts +++ b/fixtures/rpc-sanity/src/index.ts @@ -9,14 +9,26 @@ export class MyServer extends Server { async testMethod() { return this.name; } + onRequest(request: Request): Response | Promise { + const url = new URL(request.url); + if (url.pathname !== "/test") { + throw new Error("test onRequest"); + } + return new Response("test onRequest"); + } } const SESSION_ID = "session-id"; export default { async fetch(request: Request, env: Env, _ctx: ExecutionContext) { + const url = new URL(request.url); const stub = await getServerByName(env.MyServer, SESSION_ID); - const value = await stub.testMethod(); - return new Response(`the value is ${value}`); + + if (url.pathname === "/rpc") { + const value = await stub.testMethod(); + return new Response(`the value is ${value}`); + } + return stub.fetch(request); } } satisfies ExportedHandler;