feat: add API test page at /test endpoint
- New public/test-api.html — browser-based test UI for all proxy endpoints - Health check, model listing, Chat Completions (stream+non-stream), Anthropic Messages (stream+non-stream), and generic HTTP relay - Server serves /test route from public/test-api.html Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
@@ -461,6 +461,14 @@ const server: Server<WSRelayData> = Bun.serve<WSRelayData>({
|
||||
// Static routes
|
||||
if (url.pathname === "/health") return handleHealth();
|
||||
if (url.pathname === "/docs") return handleDocs();
|
||||
if (url.pathname === "/test") {
|
||||
const file = Bun.file("public/test-api.html");
|
||||
const exists = await file.exists();
|
||||
return new Response(exists ? file : "Not found", {
|
||||
status: exists ? 200 : 404,
|
||||
headers: { "Content-Type": "text/html; charset=utf-8" },
|
||||
});
|
||||
}
|
||||
if (url.pathname === "/" && req.method === "GET" && !req.headers.get("x-relay-target"))
|
||||
return handleIndex();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user