Expand description
Generic per-request timeout.
Unlike plain tower::timeout, tower_http’s TimeoutLayer never
fails the inner service — on elapse it directly returns a response with
a caller-chosen status code, so it composes onto an Axum Router with
no error-handling layer required. tower_http itself has no built-in
default status code (its zero-arg constructor is deprecated in favor of
with_status_code); timeout_layer below is this crate’s own choice
to default that code to 408 Request Timeout.
Structs§
- Timeout
Layer - Layer that applies the [
Timeout] middleware which apply a timeout to requests.
Functions§
- timeout_
layer - Build a layer that returns
408 Request Timeout(this crate’s chosen default — see the module docs) for any request taking longer thanduration. - timeout_
layer_ with_ status - Build a layer that returns
status_codefor any request taking longer thanduration.