pub struct Request {
    pub method: HttpMethod,
    pub uri: Uri,
    pub version: Version,
    pub headers: Headers,
    pub body: Body,
    pub extensions: HashMap<String, String>,
    pub path_params: HashMap<String, String>,
    pub cookies: HashMap<String, Cookie>,
    pub form_data: Option<HashMap<String, String>>,
    pub multipart: Option<MultipartForm>,
}Expand description
HTTP request type
Fields§
§method: HttpMethod§uri: Uri§version: Version§headers: Headers§body: Body§extensions: HashMap<String, String>§path_params: HashMap<String, String>Path parameters extracted from route matching
Parsed cookies
form_data: Option<HashMap<String, String>>Parsed form data (URL-encoded)
multipart: Option<MultipartForm>Parsed multipart form data
Implementations§
Source§impl Request
 
impl Request
Sourcepub fn new(method: HttpMethod, uri: Uri) -> Self
 
pub fn new(method: HttpMethod, uri: Uri) -> Self
Create a new request
Sourcepub fn set_params(&mut self, params: HashMap<String, String>)
 
pub fn set_params(&mut self, params: HashMap<String, String>)
Set path parameters (used internally by routing system)
Sourcepub async fn json<T>(&self) -> Result<T>where
    T: for<'de> Deserialize<'de>,
 
pub async fn json<T>(&self) -> Result<T>where
    T: for<'de> Deserialize<'de>,
Parse JSON body
Get cookie by name
Get all cookies
Parse cookies from headers
Sourcepub async fn parse_form(&mut self) -> Result<()>
 
pub async fn parse_form(&mut self) -> Result<()>
Parse URL-encoded form data
Sourcepub fn multipart(&self) -> Option<&MultipartForm>
 
pub fn multipart(&self) -> Option<&MultipartForm>
Get multipart form data
Sourcepub fn query_params(&self) -> HashMap<String, String>
 
pub fn query_params(&self) -> HashMap<String, String>
Parse query parameters into a HashMap
Sourcepub fn query_param(&self, name: &str) -> Option<String>
 
pub fn query_param(&self, name: &str) -> Option<String>
Get a single query parameter by name
Sourcepub fn accepts(&self, content_type: &str) -> bool
 
pub fn accepts(&self, content_type: &str) -> bool
Check if request accepts a specific content type
Sourcepub fn content_type(&self) -> Option<&str>
 
pub fn content_type(&self) -> Option<&str>
Get the content type of the request
Sourcepub fn is_multipart(&self) -> bool
 
pub fn is_multipart(&self) -> bool
Check if this is a multipart request
Sourcepub fn remote_addr(&self) -> Option<&str>
 
pub fn remote_addr(&self) -> Option<&str>
Get remote IP address (best effort)
Sourcepub fn user_agent(&self) -> Option<&str>
 
pub fn user_agent(&self) -> Option<&str>
Get user agent
Sourcepub fn path_param(&self, name: &str) -> Option<&str>
 
pub fn path_param(&self, name: &str) -> Option<&str>
Get path parameter by name
Sourcepub fn path_params(&self) -> &HashMap<String, String>
 
pub fn path_params(&self) -> &HashMap<String, String>
Get all path parameters
Sourcepub fn set_path_param(
    &mut self,
    name: impl Into<String>,
    value: impl Into<String>,
)
 
pub fn set_path_param( &mut self, name: impl Into<String>, value: impl Into<String>, )
Set a path parameter (used by router)
Sourcepub async fn parse_multipart(&mut self) -> Result<()>
 
pub async fn parse_multipart(&mut self) -> Result<()>
Parse multipart form data
Trait Implementations§
Source§impl SessionExt for Request
 
impl SessionExt for Request
Source§fn session(&self, manager: &SessionManager) -> Session
 
fn session(&self, manager: &SessionManager) -> Session
Get or create session
Auto Trait Implementations§
impl !Freeze for Request
impl RefUnwindSafe for Request
impl Send for Request
impl Sync for Request
impl Unpin for Request
impl UnwindSafe for Request
Blanket Implementations§
Source§impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
    T: 'a,
 
impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
    T: 'a,
Source§impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
    T: 'a,
 
impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
    T: 'a,
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