pub struct Request { /* private fields */ }
Expand description
Contains http request information.
Implementations§
source§impl Request
impl Request
sourcepub fn uri(&self) -> &Uri
pub fn uri(&self) -> &Uri
Get reference to Uri which contains all req path information.
let uri_info = req.uri();
let path = uri_info.path();
// and so on
sourcepub fn body(&self) -> &[u8] ⓘ
pub fn body(&self) -> &[u8] ⓘ
Get body of the request returns empty u8 if no body provided.
let req_body = req.body();
sourcepub fn params(&self) -> &Option<Vec<(&'static str, String)>>
pub fn params(&self) -> &Option<Vec<(&'static str, String)>>
Get params from related to the Router.
// if you have router with :
router.get("/:hello", |req: Request| {
// you can get `hello` param from `params`
// make sure to check if value present
let params = req.params().unwrap();
for param in params {
// param.0 is `hello` and param.1 is value
}
})