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 with_route_pattern(self, pattern: String) -> Self
pub fn with_route_pattern(self, pattern: String) -> Self
Set the route pattern (e.g., “/users/{id}”)
Sourcepub fn route_pattern(&self) -> Option<String>
pub fn route_pattern(&self) -> Option<String>
Get the route pattern for metrics grouping
Sourcepub fn insert<T: Send + Sync + 'static>(&mut self, value: T)
pub fn insert<T: Send + Sync + 'static>(&mut self, value: T)
Insert a value into the request extensions (type-map pattern)
This is async-safe unlike thread-local storage.
Sourcepub fn get<T: Send + Sync + 'static>(&self) -> Option<&T>
pub fn get<T: Send + Sync + 'static>(&self) -> Option<&T>
Get a reference to a value from the request extensions
Sourcepub fn get_mut<T: Send + Sync + 'static>(&mut self) -> Option<&mut T>
pub fn get_mut<T: Send + Sync + 'static>(&mut self) -> Option<&mut T>
Get a mutable reference to a value from the request extensions
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 query_as_or<T: FromStr>(&self, name: &str, default: T) -> T
pub fn query_as_or<T: FromStr>(&self, name: &str, default: T) -> T
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 From<&Request> for SavedInertiaContext
impl From<&Request> for SavedInertiaContext
Source§impl FromRequest for Request
Request passes through unchanged
impl FromRequest for Request
Request passes through unchanged
Source§impl InertiaRequest for Request
Implement the framework-agnostic InertiaRequest trait for Ferro’s Request type.
impl InertiaRequest for Request
Implement the framework-agnostic InertiaRequest trait for Ferro’s Request type.
Source§fn is_inertia(&self) -> bool
fn is_inertia(&self) -> bool
Source§fn inertia_version(&self) -> Option<&str>
fn inertia_version(&self) -> Option<&str>
Source§fn inertia_partial_data(&self) -> Option<Vec<&str>>
fn inertia_partial_data(&self) -> Option<Vec<&str>>
Source§fn inertia_partial_component(&self) -> Option<&str>
fn inertia_partial_component(&self) -> Option<&str>
Source§fn accepts_json(&self) -> bool
fn accepts_json(&self) -> bool
Auto Trait Implementations§
impl !Freeze for Request
impl !RefUnwindSafe for Request
impl Send for Request
impl Sync for Request
impl Unpin for Request
impl UnsafeUnpin 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
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>
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>
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