mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-05 00:00:22 +00:00
refactor(gateway): unify control-ui and plugin webhook routing
This commit is contained in:
19
src/gateway/control-ui-http-utils.ts
Normal file
19
src/gateway/control-ui-http-utils.ts
Normal file
@@ -0,0 +1,19 @@
|
||||
import type { ServerResponse } from "node:http";
|
||||
|
||||
export function isReadHttpMethod(method: string | undefined): boolean {
|
||||
return method === "GET" || method === "HEAD";
|
||||
}
|
||||
|
||||
export function respondPlainText(res: ServerResponse, statusCode: number, body: string): void {
|
||||
res.statusCode = statusCode;
|
||||
res.setHeader("Content-Type", "text/plain; charset=utf-8");
|
||||
res.end(body);
|
||||
}
|
||||
|
||||
export function respondNotFound(res: ServerResponse): void {
|
||||
respondPlainText(res, 404, "Not Found");
|
||||
}
|
||||
|
||||
export function respondMethodNotAllowed(res: ServerResponse): void {
|
||||
respondPlainText(res, 405, "Method Not Allowed");
|
||||
}
|
||||
Reference in New Issue
Block a user