Skip to content

createHttpHandler

function createHttpHandler(protocol, options?): (request) => Response | Promise<Response>;

Defined in: src/http/handler.ts:105

Create a fetch-compatible HTTP handler for a vgi-rpc Protocol.

Compatible with Bun.serve(), Deno.serve(), Cloudflare Workers, and any Web API runtime that uses the standard Request/Response types.

ParameterType
protocolProtocol
options?HttpHandlerOptions

(request) => Response | Promise<Response>

const handler = createHttpHandler(protocol);
Bun.serve({ port: 8080, fetch: handler });