Skip to main content

Module handler

Module handler 

Source
Expand description

Handlers: the Handler trait, handler closures, and the glue that turns extractor closures into stored handlers.

Most route handlers are plain async closures (|c: Call| async { ... }, or a closure taking extractors). They reach the Router via IntoHandler, which adapts a closure into a real Handler and lets it be boxed into a BoxHandler for storage.

Structs§

HandlerFnAdapter
Adapter that wraps a marker-disambiguated HandlerFn closure into a real Handler.

Traits§

Handler
Anything that can handle a Call and produce a Response.
HandlerFn
Bridge trait implemented by handler closures of a given arity. The LAST closure argument is FromCall (consuming); all earlier ones are FromCallParts (borrowing). Handlers must be Clone so the closure can be moved into the 'static response future.
IntoHandler
Bridge from a closure (or anything that is already a Handler) into a value implementing Handler, so it can be passed to boxed and the router.

Functions§

boxed
Box a Handler into a shareable BoxHandler for storage in the Router.

Type Aliases§

BoxHandler
A type-erased, shared handler — the form the Router stores. Create one with boxed.
HandlerFuture
A boxed, 'static future returned by a Handler.