Web App¶
Import: import system.webapi;
See the Web APIs guide for runnable examples, lifecycle, and error behavior.
WebApp¶
An isolated native HTTP application with explicitly mounted routers.
state¶
Application-wide values shared by every request; each request sees this map as RequestContext.app_state.
constructor¶
Creates a WebApp with default settings.
constructor¶
Creates a WebApp with options.
use¶
Appends an outer-to-inner middleware layer before startup.
include_router¶
Mounts a router with an optional additional path prefix.
override_dependencies¶
Installs generated dependency replacements before startup.
lifespan¶
Pairs one startup acquisition with its shutdown release; completed pairs unwind in reverse order.
public fun lifespan(
start: fun(WebApp): Future<Result<Unit, IoError>>,
stop: fun(WebApp): Future<void>
): Result<Unit, IoError>
shutdown¶
Stops accepting traffic and cancels active transport operations on this app.
wait¶
Drains this application's requests and releases its listener.
listen¶
Binds this app with the default ServerConfig and returns the bound port; port zero selects an ephemeral port.
public fun listen(
host: string,
port: int,
token: Option<CancellationToken> = Option.None
): Future<Result<int, IoError>>
listen¶
Binds this app with the transport settings in config and returns the bound port; port zero selects an ephemeral port. Negative settings fail with EINVAL.
public fun listen(
host: string,
port: int,
config: ServerConfig,
token: Option<CancellationToken> = Option.None
): Future<Result<int, IoError>>
run¶
Listens with the default ServerConfig and waits until shutdown or cancellation.
public fun run(
host: string,
port: int,
token: Option<CancellationToken> = Option.None
): Future<Result<Unit, IoError>>
run¶
Listens with config and waits until shutdown or cancellation, like uvicorn.run.
public fun run(
host: string,
port: int,
config: ServerConfig,
token: Option<CancellationToken> = Option.None
): Future<Result<Unit, IoError>>
openapi¶
Produces documentation for this application's mounted routes only.