pub struct RequestContext {
pub headers: HeaderMap,
pub request_id: String,
pub method: String,
pub path: String,
pub remote_addr: Option<SocketAddr>,
}Expand description
Request context passed to all handler methods
Fields§
§headers: HeaderMapHTTP headers from the request
request_id: StringRequest ID for tracing
method: StringHTTP method (GET, POST)
path: StringRequest path
remote_addr: Option<SocketAddr>Remote client address
Implementations§
Source§impl RequestContext
impl RequestContext
pub fn new( headers: HeaderMap, method: String, path: String, remote_addr: Option<SocketAddr>, ) -> Self
Sourcepub fn get_header(&self, name: &str) -> Option<String>
pub fn get_header(&self, name: &str) -> Option<String>
Get a header value as string
Get authorization header
Sourcepub fn get_bearer_token(&self) -> Option<String>
pub fn get_bearer_token(&self) -> Option<String>
Get bearer token from authorization header
Sourcepub fn get_custom_header(&self, name: &str) -> Option<String>
pub fn get_custom_header(&self, name: &str) -> Option<String>
Get custom header by name
Trait Implementations§
Source§impl Clone for RequestContext
impl Clone for RequestContext
Source§fn clone(&self) -> RequestContext
fn clone(&self) -> RequestContext
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreAuto Trait Implementations§
impl Freeze for RequestContext
impl RefUnwindSafe for RequestContext
impl Send for RequestContext
impl Sync for RequestContext
impl Unpin for RequestContext
impl UnwindSafe for RequestContext
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more