pub struct Request {
pub method: Method,
pub uri: Uri,
pub version: Version,
pub headers: HeaderMap,
pub body: Bytes,
pub extensions: Extensions,
/* private fields */
}Expand description
Contains a incoming Http Request
Fields§
§method: MethodThe HTTP method of the request.
For example, GET, POST, PUT, DELETE, etc.
uri: UriThe URI of the request.
version: VersionThe HTTP version of the request.
headers: HeaderMapThe headers of the request.
body: BytesThe body of the request.
extensions: ExtensionsThe extensions of the request.
Implementations§
Source§impl Request
impl Request
Sourcepub fn parse(raw: &[u8]) -> Result<Request, Box<dyn Error>>
pub fn parse(raw: &[u8]) -> Result<Request, Box<dyn Error>>
Parses a Request from raw bytes if parsing fails returns a error
Sourcepub fn json(&self) -> Result<Value, Box<dyn Error>>
pub fn json(&self) -> Result<Value, Box<dyn Error>>
Parses the body of the request as Serde JSON Value. Returns an error if the body is not valid JSON.
This method is useful for parsing JSON payloads in requests.
Sourcepub fn query(&self) -> Result<HashMap<String, String>, Box<dyn Error>>
pub fn query(&self) -> Result<HashMap<String, String>, Box<dyn Error>>
Returns a Hashmap of the query parameters of the Request.
Returns a Error if parsing fails
pub fn set_params(&mut self, params: HashMap<String, String>)
pub fn param(&self, key: &str) -> Option<&str>
Trait Implementations§
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