FastAPIAdapter Class
Default HttpServerAdapter implementation wrapping FastAPI + uvicorn.
Constructor
FastAPIAdapter(app: FastAPI | None = None, server_factory: Callable[[FastAPI], Server] | None = None)
Parameters
| Name | Description |
|---|---|
|
app
|
Default value: None
|
|
server_factory
|
Default value: None
|
Methods
| register_route |
Register a route handler on the FastAPI app. |
| serve_static |
Mount a static files directory. |
| start |
Start the uvicorn server. Blocks until stopped. |
| stop |
Signal the server to stop. |
register_route
Register a route handler on the FastAPI app.
register_route(method: Literal['POST'], path: str, handler: HttpRouteHandler) -> None
Parameters
| Name | Description |
|---|---|
|
method
Required
|
|
|
path
Required
|
|
|
handler
Required
|
|
serve_static
Mount a static files directory.
serve_static(path: str, directory: str) -> None
Parameters
| Name | Description |
|---|---|
|
path
Required
|
|
|
directory
Required
|
|
start
Start the uvicorn server. Blocks until stopped.
async start(port: int) -> None
Parameters
| Name | Description |
|---|---|
|
port
Required
|
|
stop
Signal the server to stop.
async stop() -> None
Attributes
app
The underlying FastAPI instance.
lifespans
lifespans: List[Callable[[Callable[[MutableMapping[str, Any], Callable[[], Awaitable[MutableMapping[str, Any]]], Callable[[MutableMapping[str, Any]], Awaitable[None]]], Awaitable[None]]], AbstractAsyncContextManager[None]] | Callable[[Callable[[MutableMapping[str, Any], Callable[[], Awaitable[MutableMapping[str, Any]]], Callable[[MutableMapping[str, Any]], Awaitable[None]]], Awaitable[None]]], AbstractAsyncContextManager[Mapping[str, Any]]]]