Skip to main content

Module rejection

Module rejection 

Source
Expand description

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.

not_found_handler is wired into apps/soma’s router .fallback(). method_not_allowed is available for a product router to wire up (via Axum’s per-route method fallback) but is not currently mounted anywhere — Axum’s .fallback() only intercepts unmatched paths, not matched-path/disallowed-method requests, so a consumer must opt in separately for 405s to use this envelope.

Functions§

method_not_allowed
Render a 405 Method Not Allowed body: {"error": "method_not_allowed"}.
not_found
Render a 404 Not Found body: {"error": "not_found"}.
not_found_handler
Axum .fallback() handler wrapping not_found. Mount with router.fallback(not_found_handler).