pub trait IHttpRequest: Send {
// Required methods
fn method(&self) -> &str;
fn path(&self) -> &str;
fn header(&self, name: &str) -> Option<&str>;
fn query(&self) -> &HashMap<String, String>;
fn route_params(&self) -> &HashMap<String, String>;
fn route_params_mut(&mut self) -> &mut HashMap<String, String>;
fn route_pattern(&self) -> Option<&str>;
fn route_pattern_mut(&mut self) -> &mut Option<String>;
fn body_bytes<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<Vec<u8>>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait;
// Provided method
fn body_text<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<String>> + Send + 'async_trait>>
where Self: Sync + 'async_trait,
'life0: 'async_trait { ... }
}Expand description
HTTP request abstraction.
Analogous to ASP.NET Core’s HttpRequest.
Methods are non-generic to maintain dyn-compatibility.
Use serde_json::from_slice on the raw body bytes for JSON deserialization.
Required Methods§
fn method(&self) -> &str
fn path(&self) -> &str
fn header(&self, name: &str) -> Option<&str>
fn query(&self) -> &HashMap<String, String>
fn route_params(&self) -> &HashMap<String, String>
fn route_params_mut(&mut self) -> &mut HashMap<String, String>
Sourcefn route_pattern(&self) -> Option<&str>
fn route_pattern(&self) -> Option<&str>
The original route pattern that was matched (e.g., "/api/users/{id}").
Set by the router after successful route matching.
fn route_pattern_mut(&mut self) -> &mut Option<String>
Provided Methods§
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".