std::http::middleware¶
Status: experimental
Composable middleware: logger, recoverer, request_id, cors, basic_auth, compress_gzip.
API details and source¶
The implementation source contains the complete declarations and implementation notes. The table below lists canonical Gossamer call signatures; every item name links directly to its implementation file.
| Item | Canonical signature or declaration | Description |
|---|---|---|
Chain |
type Chain |
Helper for composing middleware in a single value. |
Handler |
trait Handler |
Anything serving (Request, Params) -> Response. |
accepts_gzip |
fn accepts_gzip(request: http::Request) -> bool |
Check an Accept-Encoding header for a gzip token. Available in interp + compiled. |
bearer_ok |
fn bearer_ok(request: http::Request, verify: Fn(String) -> bool) -> bool |
Run a verify closure on the request's Bearer token; false (without calling verify) when no Bearer header is present. Available in interp + compiled. |
decode_basic_auth |
fn decode_basic_auth(request: http::Request) -> Option<(String, String)> |
Decode a Basic-auth Authorization header into (user, password). Interp tier. |
new_request_id |
fn new_request_id() -> String |
Generate a process-monotonic request id string. Available in interp + compiled. |
tag |
fn tag(handler: http::Handler) -> http::Handler |
Wrap a handler (tag(inner) -> Handler), prepending mw: to each response body. Deterministic composition primitive; available in interp + compiled. |