Skip to main content

Handler

Type Alias Handler 

Source
pub type Handler<S> = Arc<dyn Fn(Request<Incoming>, State<S>) -> Pin<Box<dyn Future<Output = Result<Response<ResponseBody>, ServeError>> + Send>> + Send + Sync>;
Expand description

A request handler that processes an HTTP request and returns a response or error.

Handlers receive the full request (method, path, headers, body) and the app state, and return either a response or a ServeError (which is converted to an HTTP error response).

Aliased Typeยง

pub struct Handler<S> { /* private fields */ }