pub struct ElifRequest {
pub method: Method,
pub uri: Uri,
pub headers: HeaderMap,
pub path_params: HashMap<String, String>,
pub query_params: HashMap<String, String>,
/* private fields */
}Expand description
Request abstraction that wraps Axum’s request types with additional parsing and extraction capabilities
Fields§
§method: Method§uri: Uri§headers: HeaderMap§path_params: HashMap<String, String>§query_params: HashMap<String, String>Implementations§
Source§impl ElifRequest
impl ElifRequest
Sourcepub fn new(method: Method, uri: Uri, headers: HeaderMap) -> Self
pub fn new(method: Method, uri: Uri, headers: HeaderMap) -> Self
Create new ElifRequest from Axum components
Sourcepub fn with_path_params(self, params: HashMap<String, String>) -> Self
pub fn with_path_params(self, params: HashMap<String, String>) -> Self
Set path parameters extracted from route
Sourcepub fn with_query_params(self, params: HashMap<String, String>) -> Self
pub fn with_query_params(self, params: HashMap<String, String>) -> Self
Set query parameters
Sourcepub fn path_param(&self, name: &str) -> Option<&String>
pub fn path_param(&self, name: &str) -> Option<&String>
Get path parameter by name
Sourcepub fn path_param_parsed<T>(&self, name: &str) -> HttpResult<T>
pub fn path_param_parsed<T>(&self, name: &str) -> HttpResult<T>
Get path parameter by name, parsed to specific type
Sourcepub fn query_param(&self, name: &str) -> Option<&String>
pub fn query_param(&self, name: &str) -> Option<&String>
Get query parameter by name
Sourcepub fn query_param_parsed<T>(&self, name: &str) -> HttpResult<Option<T>>
pub fn query_param_parsed<T>(&self, name: &str) -> HttpResult<Option<T>>
Get query parameter by name, parsed to specific type
Sourcepub fn query_param_required<T>(&self, name: &str) -> HttpResult<T>
pub fn query_param_required<T>(&self, name: &str) -> HttpResult<T>
Get required query parameter by name, parsed to specific type
Sourcepub fn header(&self, name: &str) -> Option<&HeaderValue>
pub fn header(&self, name: &str) -> Option<&HeaderValue>
Get header value by name
Sourcepub fn header_string(&self, name: &str) -> HttpResult<Option<String>>
pub fn header_string(&self, name: &str) -> HttpResult<Option<String>>
Get header value as string
Sourcepub fn content_type(&self) -> HttpResult<Option<String>>
pub fn content_type(&self) -> HttpResult<Option<String>>
Get Content-Type header
Sourcepub fn body_bytes(&self) -> Option<&Bytes>
pub fn body_bytes(&self) -> Option<&Bytes>
Get request body as bytes
Sourcepub fn json<T: DeserializeOwned>(&self) -> HttpResult<T>
pub fn json<T: DeserializeOwned>(&self) -> HttpResult<T>
Parse JSON body to specified type
Sourcepub fn form<T: DeserializeOwned>(&self) -> HttpResult<T>
pub fn form<T: DeserializeOwned>(&self) -> HttpResult<T>
Parse form data body to specified type
Sourcepub fn user_agent(&self) -> HttpResult<Option<String>>
pub fn user_agent(&self) -> HttpResult<Option<String>>
Get User-Agent header
Get Authorization header
Sourcepub fn bearer_token(&self) -> HttpResult<Option<String>>
pub fn bearer_token(&self) -> HttpResult<Option<String>>
Extract Bearer token from Authorization header
Sourcepub fn client_ip(&self) -> HttpResult<Option<String>>
pub fn client_ip(&self) -> HttpResult<Option<String>>
Get request IP address from headers or connection
Sourcepub fn query_string(&self) -> Option<&str>
pub fn query_string(&self) -> Option<&str>
Get query string
Trait Implementations§
Source§impl Debug for ElifRequest
impl Debug for ElifRequest
Source§impl RequestExtractor for ElifRequest
impl RequestExtractor for ElifRequest
Source§fn extract_elif_request(
method: Method,
uri: Uri,
headers: HeaderMap,
body: Option<Bytes>,
) -> ElifRequest
fn extract_elif_request( method: Method, uri: Uri, headers: HeaderMap, body: Option<Bytes>, ) -> ElifRequest
Extract ElifRequest from request components
Auto Trait Implementations§
impl !Freeze for ElifRequest
impl RefUnwindSafe for ElifRequest
impl Send for ElifRequest
impl Sync for ElifRequest
impl Unpin for ElifRequest
impl UnwindSafe for ElifRequest
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> 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