pub struct StateMiddleware<T>(_);
Expand description

The middleware for inserting state into a request.

This inserts the inner state value into the request every time the middleware is run, before passing on the request down stream. You can append as many state middlewares as you like, as long as the inner type T does not overlap (otherwise, the last value would win).

This type requires the inner type to be Clone, as it must be cloned on every request. It is recommended to wrap the type in a reference-counting type, like std::sync::Arc, if it is not already in one.

Implementations

Creates an instance of the state middleware with the given value.

Examples
under::http()
    .with(under::middleware::StateMiddleware::new(123u32));

Trait Implementations

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

Formats the value using the given formatter. Read more

Handles the given request, returning a response. The next parameter contains the information on how to process everything after the current middleware, i.e. generating a response from the endpoint. Read more

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more

Instruments this type with the current Span, returning an Instrumented wrapper. Read more

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

The resulting type after obtaining ownership.

Creates owned data from borrowed data, usually by cloning. Read more

🔬 This is a nightly-only experimental API. (toowned_clone_into)

Uses borrowed data to replace owned data, usually by cloning. Read more

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more