Skip to navigation

Static method that creates a CGI handler from a Hono app. Each call of the returned function performs one CGI request/response cycle: it reads the request from the CGI environment and standard input, routes it through the app, and writes the CGI response (status line, headers, a blank line, then the body) to standard output.

Parameters

app
{ fetch: (req: Request, env?: Record<string, unknown>) => Response | Promise<Response> }Required

A Hono-compatible application with a fetch method.

Returns

() => Promise<void> — A function that handles one CGI request.

Example

import { AgentBase, ServerlessAdapter } from '@signalwire/sdk';
const agent = new AgentBase({ name: 'dispatch', route: '/dispatch' });
agent.setPromptText('You are Ada, the dispatcher for Bayview Taxi.');
const handle = ServerlessAdapter.createCgiHandler(agent.getApp());
await handle();