Struct Request

Source
pub struct Request {
    pub method: Option<HttpMethod>,
    pub uri: String,
    pub user_agent: String,
    pub user_addr: SocketAddr,
    pub get_request: HashMap<String, String>,
    pub post_request: HashMap<String, PostRequest>,
    pub raw_request: Vec<String>,
    pub secure: bool,
}
Expand description

§Request

Handles requests from users, and returns it in a friendly, safe way.

Can be used to gather POST and GET info, user-agent information and more

If you have custom headers, and want to access them, use raw_request to access the raw unmodified request

Fields§

§method: Option<HttpMethod>

Method stores the method used to make the request

§uri: String

URI contains the URI of the request

§user_agent: String

User Agent stores the user agent of the user

§user_addr: SocketAddr

User Addr stores the users IP address

§get_request: HashMap<String, String>

Get Request stores the data of the get request.

It is a HashMap<String, String>

The key of the hashmap is equal to the name of the form field name.

§post_request: HashMap<String, PostRequest>

Post Request stores the data of the post request.

It is a HashMap<String, PostRequest>

The key of the hashmap is equal to the name of the form field name.

§raw_request: Vec<String>

Raw Request stores the raw request without any modifications.

§secure: bool

Did the request come from a secure connection?

Implementations§

Source§

impl Request

Source

pub async fn new( request: String, user_addr: SocketAddr, is_secure: bool, ) -> Result<Self, &'static str>

§New

Create a new request struct.

Takes an input string (Which should be the request).

It will then construct itself and return, ready to use.

Trait Implementations§

Source§

impl Debug for Request

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

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.