MCPcopy Create free account
hub / github.com/cloudflare/computer / fetch

Function fetch

examples/assets/src/index.ts:126–144  ·  view source on GitHub ↗
(request: Request, env: Env)

Source from the content-addressed store, hash-verified

124
125export default {
126 async fetch(request: Request, env: Env): Promise<Response> {
127 const url = new URL(request.url);
128
129 if (url.pathname === "/" || url.pathname === "") {
130 return new Response(
131 ["assets example", "", ' POST /prompt { "prompt": "..." }', ""].join("\n"),
132 { headers: { "content-type": "text/plain" } },
133 );
134 }
135
136 if (url.pathname === "/prompt") {
137 if (request.method !== "POST") {
138 return new Response("method not allowed", { status: 405, headers: { allow: "POST" } });
139 }
140 return handlePrompt(request, env);
141 }
142
143 return new Response("not found", { status: 404 });
144 },
145} satisfies ExportedHandler<Env>;
146
147interface PromptRequest {

Callers

nothing calls this directly

Calls 1

handlePromptFunction · 0.85

Tested by

no test coverage detected