Struct peta::Request

source ·
pub struct Request { /* private fields */ }
Expand description

Contains http request information.

Implementations§

Get reference to Uri which contains all req path information.

let uri_info = req.uri();
let path = uri_info.path();
// and so on

Get body of the request returns empty u8 if no body provided.

let req_body = req.body();

Get request method.

let method = req.method();

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
  }
})

Get request http version (minor http version)

// version will be 1 -> http 1.1 and 0 -> http 1.0
let version = req.version();

Get http request headers

let headers = req.headers();

for header in headers {
   // header.0 is header name and header.1 is value
}

Auto Trait Implementations§

Blanket Implementations§

Gets the TypeId of self. Read more
Immutably borrows from an owned value. Read more
Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

The type returned in the event of a conversion error.
Performs the conversion.
The type returned in the event of a conversion error.
Performs the conversion.