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,
Source§type Transform = RequestIdMiddleware<S>
type Transform = RequestIdMiddleware<S>
TransformService
value created by this factory