Request

Struct Request 

Source
pub struct Request {
    pub method: HttpMethod,
    pub path: String,
    /* private fields */
}
Expand description

HTTP request

A request is composed of:

  • HTTP method (GET, POST, PUT, DELETE, … )
  • Target URL, for example, https://myservice.com/users
  • (optional) Request headers.
  • (optional) Request path parameters, for example, id in the URL https://myservice.com/users?id=1111.
  • (optional) Server cookies
  • (optional) Request body of type Vec[u8]

Request headers, parameters and cookies are represented by a pair of name and value strings. Additionally, a HttpConfig struct can be used to configure the HTTP connections stablished to send a Request and receive a Response.

For more information see HTTP Request.

Fields§

§method: HttpMethod

HTTP method

§path: String

Request path

Implementations§

Source§

impl Request

Source

pub fn has_body(&self) -> bool

Checks if this request has body

Source

pub fn url(&self) -> &str

Source

pub fn send(&mut self) -> Result<Response, Error>

Sends the request to the target URL. Returns the Response message or std::io::Error if any issue happened.

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> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

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

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.