pub struct RequestIdentifier { /* private fields */ }
Expand description
A middleware for generating per-request unique IDs
Implementations§
source§impl RequestIdentifier
impl RequestIdentifier
sourcepub fn with_uuid() -> Self
pub fn with_uuid() -> Self
Create a default middleware using DEFAULT_HEADER
as the header name and
UUID v4 for ID generation.
sourcepub fn with_header(header_name: &'static str) -> Self
pub fn with_header(header_name: &'static str) -> Self
Create a middleware using a custom header name and UUID v4 for ID generation.
sourcepub const fn header(self, header_name: &'static str) -> Self
pub const fn header(self, header_name: &'static str) -> Self
Change the header name for this middleware.
sourcepub fn with_generator(id_generator: fn() -> HeaderValue) -> Self
pub fn with_generator(id_generator: fn() -> HeaderValue) -> Self
Create a middleware using DEFAULT_HEADER
as the header
name and IDs as generated by id_generator
. id_generator
should return a unique ID
(ASCII only), each time it is invoked.
sourcepub fn generator(self, id_generator: fn() -> HeaderValue) -> Self
pub fn generator(self, id_generator: fn() -> HeaderValue) -> Self
Change the ID generator for this middleware.
sourcepub fn use_incoming_id(self, use_incoming_id: IdReuse) -> Self
pub fn use_incoming_id(self, use_incoming_id: IdReuse) -> Self
Change the behavior for incoming request id headers. When this is set to
IdReuse::UseIncoming
(the default), each request is checked if it
contains a header by the specified name and if it exists, the id from that header is used, otherwise a random id
is generated. When this is set to IdReuse::IgnoreIncoming
, the
id from the request header is ignored.
Trait Implementations§
source§impl Default for RequestIdentifier
impl Default for RequestIdentifier
source§impl<S, B> Transform<S, ServiceRequest> for RequestIdentifierwhere
S: Service<ServiceRequest, Response = ServiceResponse<B>, Error = Error>,
S::Future: 'static,
B: 'static,
impl<S, B> Transform<S, ServiceRequest> for RequestIdentifierwhere
S: Service<ServiceRequest, Response = ServiceResponse<B>, Error = Error>,
S::Future: 'static,
B: 'static,
§type Response = <S as Service<ServiceRequest>>::Response
type Response = <S as Service<ServiceRequest>>::Response
§type Error = <S as Service<ServiceRequest>>::Error
type Error = <S as Service<ServiceRequest>>::Error
§type Transform = RequestIdMiddleware<S>
type Transform = RequestIdMiddleware<S>
TransformService
value created by this factory