Skip to main content

Module server

Module server 

Source
Expand description

Axum router on a Unix domain socket; the serve entrypoint.

Per 20-firecracker-api.md § 2:

  • Every response carries Server: Firecracker API (a SetResponseHeaderLayer).
  • Bodies above --http-api-max-payload-size return 413 Payload Too Large via tower_http::limit::RequestBodyLimitLayer.
  • Unknown paths are translated by the fallback into 400 BadRequest with {"fault_message": "No such resource: ..."}.

The handler set lives in crate::handlers; this module is just plumbing.

Structs§

ServeOptions
Configuration for serve.

Constants§

DEFAULT_MAX_PAYLOAD
Default Firecracker-compat HTTP body limit (51200 bytes); overridable via ServeOptions.
FIRECRACKER_SERVER_HEADER
The literal value upstream Firecracker emits for the Server header. SDKs and orchestrator-side smoke tests sniff this string; we emit it verbatim.
MAX_MAX_PAYLOAD
Upper bound on the body limit.
MIN_MAX_PAYLOAD
Lower bound on the body limit (70-security.md § 6).

Functions§

bind_listener
Bind a Unix domain socket for serve_bound.
router
Build the axum router with all middleware applied. Exposed for use in integration tests (callers can wrap it in axum::serve against any tokio::net::UnixListener).
serve
Bind a Unix domain socket and serve the API on it until the future is dropped.
serve_bound
Serve the API on an already-bound Unix listener until the future is dropped.
unlink_socket_if_exists
Best-effort cleanup helper: unlinks path if present, ignoring NotFound.