Skip to main content

Crate soma_http_server

Crate soma_http_server 

Source
Expand description

Reusable Axum server plumbing (plan section 3.12).

soma-http-api (plan section 3.11) owns reusable API surface shapes — response envelopes, error/problem-details bodies, probe DTOs, route inventory metadata. This crate owns the layer below that: generic transport lifecycle mechanics — listener binding, the Axum server run loop, graceful shutdown, request-ID/tracing/timeout/body-limit middleware, generic CORS configuration, generic health-check routing, and a generic not-found/method-not-allowed rejection envelope.

This crate must stay product-agnostic: no /v1/* Soma routes, no Soma action names, no product auth policy, no Soma OpenAPI document content, no embedded Soma UI assets, no action dispatch. Product routers compose themselves out of these primitives; they do not belong here.

Re-exports§

pub use server::bind;
pub use server::serve;
pub use server::serve_with_shutdown;
pub use server::ServerError;
pub use shutdown::shutdown_signal;

Modules§

health
Generic health-check route wiring.
middleware
Generic request middleware: request IDs, tracing, timeouts, body limits, and CORS. Every helper here takes its policy (durations, byte limits, allowed origins/methods/headers) as parameters — none of it is Soma policy, only Axum/tower-http mechanics.
rejection
Generic rejection envelopes for routing-level failures: unmatched routes and disallowed methods. Rendered through soma_http_api’s structured error body so any HTTP surface that mounts these renders the same shape for the same failure class. Body-extraction rejections (malformed JSON, payload too large) are soma_http_api::response::json_rejection_response — an API-shape concern, not a transport concern, so they live there instead.
server
Listener binding and the Axum server run loop.
shutdown
Graceful shutdown signal.