Router
A synchronous HTTP router.
Usage
Router()Parameters
prefix: str = ""-
URL prefix for all routes.
deps: dict | None = None-
Dependency injection mapping.
Methods
| Name | Description |
|---|---|
| get() | Register a GET route. |
| post() | Register a POST route. |
| static() | Serve static files. |
| use() | Add middleware to the router. |
get()
Register a GET route.
Usage
get(path, handler=None)Parameters
path: str-
URL path pattern.
handler=None-
Request handler callable.
post()
Register a POST route.
Usage
post(path, handler=None)Parameters
path: str-
URL path pattern.
handler=None-
Request handler callable.
static()
Serve static files.
Usage
static(url_path, dir_path)Parameters
url_path: str-
URL prefix for static files.
dir_path: str-
Local directory path.
use()
Add middleware to the router.
Usage
use(middleware)Parameters
middleware-
Middleware callable.