Skip to main content

with_timeout

Function with_timeout 

Source
pub fn with_timeout<F>(
    duration: Duration,
    handler: F,
) -> impl Fn(&Request, &PathParams, &ConnectionInfo) -> Response + Send + Sync + 'static
where F: Fn(&Request, &PathParams, &ConnectionInfo) -> Response + Send + Sync + 'static,
Expand description

Wraps a stateless handler (the Router handler signature) so it must complete within duration or the caller gets 504 Gateway Timeout instead of waiting further. See the module docs for the cancellation caveat.