HttpServerAdapter Class
Protocol for framework-specific HTTP server adapters.
Implement this adapter to plug in any HTTP framework (FastAPI, Starlette, Flask, etc.).
The SDK calls these methods with framework-agnostic HttpRequest/HttpResponse
objects so the adapter can translate to/from the underlying framework.
Constructor
HttpServerAdapter(*args, **kwargs)
Methods
| register_route |
Register a route handler. Required. |
| serve_static |
Serve static files from a directory. Optional — no-op by default. |
| start |
Start the server. Optional — raises if not implemented. |
| stop |
Stop the server. Optional — no-op by default. |
register_route
Register a route handler. Required.
register_route(method: Literal['POST'], path: str, handler: HttpRouteHandler) -> None
Parameters
| Name | Description |
|---|---|
|
method
Required
|
|
|
path
Required
|
|
|
handler
Required
|
|
serve_static
Serve static files from a directory. Optional — no-op by default.
serve_static(path: str, directory: str) -> None
Parameters
| Name | Description |
|---|---|
|
path
Required
|
|
|
directory
Required
|
|
start
Start the server. Optional — raises if not implemented.
async start(port: int) -> None
Parameters
| Name | Description |
|---|---|
|
port
Required
|
|
stop
Stop the server. Optional — no-op by default.
async stop() -> None