Skip to main content

timeout_handler

Function timeout_handler 

Source
pub fn timeout_handler(
    handler: impl Handler + 'static,
    timeout: Duration,
    body: &'static str,
) -> impl Handler
Expand description

Wraps handler with a per-request deadline.

If the handler does not complete within timeout the connection receives body with status 503. The handler runs in a spawned goroutine; the caller goroutine selects on a done channel vs a timeout context.

Port of Go’s http.TimeoutHandler.