pub struct Request { /* private fields */ }Expand description
HTTP Request wrapper providing Laravel-like access to request data
Implementations§
Source§impl Request
impl Request
pub fn new(inner: Request<Incoming>) -> Self
pub fn with_params(self, params: HashMap<String, String>) -> Self
Sourcepub fn param(&self, name: &str) -> Result<&str, ParamError>
pub fn param(&self, name: &str) -> Result<&str, ParamError>
Get a route parameter by name (e.g., /users/{id})
Returns Err(ParamError) if the parameter is missing, enabling use of ? operator
Sourcepub fn content_type(&self) -> Option<&str>
pub fn content_type(&self) -> Option<&str>
Get the Content-Type header
Sourcepub fn is_inertia(&self) -> bool
pub fn is_inertia(&self) -> bool
Check if this is an Inertia XHR request
Sourcepub fn inertia_version(&self) -> Option<&str>
pub fn inertia_version(&self) -> Option<&str>
Get the Inertia version from request headers
Sourcepub fn inertia_partial_component(&self) -> Option<&str>
pub fn inertia_partial_component(&self) -> Option<&str>
Get partial component name for partial reloads
Sourcepub fn inertia_partial_data(&self) -> Option<Vec<&str>>
pub fn inertia_partial_data(&self) -> Option<Vec<&str>>
Get partial data keys for partial reloads
Sourcepub async fn body_bytes(self) -> Result<(RequestParts, Bytes), FrameworkError>
pub async fn body_bytes(self) -> Result<(RequestParts, Bytes), FrameworkError>
Consume the request and collect the body as bytes
Sourcepub async fn json<T: DeserializeOwned>(self) -> Result<T, FrameworkError>
pub async fn json<T: DeserializeOwned>(self) -> Result<T, FrameworkError>
Sourcepub async fn form<T: DeserializeOwned>(self) -> Result<T, FrameworkError>
pub async fn form<T: DeserializeOwned>(self) -> Result<T, FrameworkError>
Sourcepub async fn input<T: DeserializeOwned>(self) -> Result<T, FrameworkError>
pub async fn input<T: DeserializeOwned>(self) -> Result<T, FrameworkError>
Parse the request body based on Content-Type header
application/json-> JSON parsingapplication/x-www-form-urlencoded-> Form parsing- Otherwise -> JSON parsing (default)
Consumes the request since the body can only be read once.
Sourcepub fn into_parts(self) -> (RequestParts, Incoming)
pub fn into_parts(self) -> (RequestParts, Incoming)
Consume the request and return its parts along with the inner hyper request body
This is used internally by the handler macro for FormRequest extraction.
Trait Implementations§
Source§impl FromRequest for Request
Request passes through unchanged
impl FromRequest for Request
Request passes through unchanged
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<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