Skip to main content

layer

Function layer 

Source
pub fn layer() -> FromFnLayer<impl FnMut(Request, Next) -> WithContext + Clone, (), (Request,)>
Available on crate feature http only.
Expand description

Attach a Context to every request.

The one piece of wiring api! requires:

ⓘ
let app = routes()
    .layer(ash_jsonapi::layer())
    .with_state(state);

The correlation id is the client’s X-Request-Id where it sent one, and a generated id otherwise. Either way it is echoed back on the response, so a client can quote it, and it is the id on every error object this crate returns — the thread tying a failed response to the log line explaining it.

Add authentication after this layer and extend the context it built, rather than replacing it — see the module docs.