ApiRequest
Represents an incoming HTTP request with parsed parameters and body.- TypeScript
- Python
- Rust
Fields
object
required
Path parameters extracted from the URL pattern (e.g.,
/users/:id → { id: "123" }).object
required
Query string parameters. Values can be strings or arrays for repeated parameters.
TBody
required
The parsed request body. Type can be specified via generic parameter.
object
required
HTTP headers. Values can be strings or arrays for repeated headers.
string
required
HTTP method (GET, POST, PUT, PATCH, DELETE, etc.).
ApiResponse
Represents an HTTP response to be sent back to the client.- TypeScript
- Python
- Rust
Fields
number
required
HTTP status code (200, 404, 500, etc.).
object
Response headers to include.
TBody
Response body. Can be a string, Buffer, or object (automatically JSON serialized).
HttpRequest
For streaming HTTP handlers, includes access to the request body stream.- TypeScript
- Python
- Rust
Additional Fields
ChannelReader
required
Stream reader for accessing the raw request body as chunks.
HttpResponse
Streaming response writer for HTTP handlers.- TypeScript
- Python
- Rust
Methods
function
required
Set the HTTP status code for the response.
function
required
Set response headers.
WritableStream
required
Writable stream for sending response body chunks.
function
required
Close the response stream and complete the HTTP response.
Usage Examples
Simple API Handler
- TypeScript
- Python
- Rust
Streaming Response
- TypeScript
- Python
- Rust