mirror of
https://github.com/openclaw/openclaw.git
synced 2026-03-29 10:50:58 +00:00
21 lines
529 B
TypeScript
21 lines
529 B
TypeScript
export function jsonResponse(body: unknown, status = 200): Response {
|
|
return new Response(JSON.stringify(body), {
|
|
status,
|
|
headers: { "Content-Type": "application/json" },
|
|
});
|
|
}
|
|
|
|
export function requestUrl(input: string | URL | Request): string {
|
|
if (typeof input === "string") {
|
|
return input;
|
|
}
|
|
if (input instanceof URL) {
|
|
return input.toString();
|
|
}
|
|
return input.url;
|
|
}
|
|
|
|
export function requestBodyText(body: BodyInit | null | undefined): string {
|
|
return typeof body === "string" ? body : "{}";
|
|
}
|