Trait rama::http::layer::set_header::response::MakeHeaderValueFactory
pub trait MakeHeaderValueFactory<S, ReqBody, ResBody>:
Send
+ Sync
+ 'static {
type Maker: MakeHeaderValue<ResBody>;
// Required method
fn make_header_value_maker(
&self,
ctx: Context<S>,
request: Request<ReqBody>,
) -> impl Future<Output = (Context<S>, Request<ReqBody>, Self::Maker)> + Send;
}
Expand description
Trait for preparing a maker (MakeHeaderValue
) that will be used
to actually create the HeaderValue
when desired.
The reason why this is split in two parts for responses is because
the context is consumed by the inner service producting the response
to which the header (maybe) will be attached to. In order to not
clone the entire Context
and its State
it is therefore better
to let the implementer decide what state is to be cloned and which not.
E.g. for a static Header value one might not need any state or context at all, which would make it pretty wastefull if we would for such cases clone these stateful datastructures anyhow.
Most users will however not have to worry about this Trait or why it is there, as the trait is implemented already for functions, closures and HeaderValues.
Required Associated Types§
type Maker: MakeHeaderValue<ResBody>
type Maker: MakeHeaderValue<ResBody>
Maker that can be produced by this Factory.