funny curl

This commit is contained in:
2026-07-20 17:05:24 -05:00
parent 7369afb6bb
commit fbb9003ba9
3 changed files with 208 additions and 0 deletions
+22
View File
@@ -0,0 +1,22 @@
import curlResponse from "../src/curl-response.ts";
interface PagesContext {
request: Request;
next(): Promise<Response>;
}
export function onRequest(context: PagesContext): Response | Promise<Response> {
const { request } = context;
const userAgent = request.headers.get("user-agent") ?? "";
const pathname = new URL(request.url).pathname;
if (
request.method === "GET" &&
pathname === "/" &&
/^curl(?:\/|$)/i.test(userAgent)
) {
return curlResponse();
}
return context.next();
}