Struct salvo::Request[][src]

pub struct Request { /* fields omitted */ }

Represents an HTTP request.

Stores all the properties of the client’s request.

Implementations

impl Request[src]

pub fn new() -> Request[src]

Creates a new blank Request

pub fn from_hyper(req: Request<Body>) -> Request[src]

Create a request from an hyper::Request.

This constructor consumes the hyper::Request.

pub fn uri(&self) -> &Uri[src]

Returns a reference to the associated URI.

Examples

let request = Request::default();
assert_eq!(*request.uri(), *"/");

pub fn uri_mut(&mut self) -> &mut Uri[src]

Returns a mutable reference to the associated URI.

Examples

let mut request: Request= Request::default();
*request.uri_mut() = "/hello".parse().unwrap();
assert_eq!(*request.uri(), *"/hello");

pub fn method(&self) -> &Method[src]

Returns a reference to the associated HTTP method.

Examples

let request = Request::default();
assert_eq!(*request.method(), Method::GET);

pub fn method_mut(&mut self) -> &mut Method[src]

Returns a mutable reference to the associated HTTP method.

Examples

let mut request: Request = Request::default();
*request.method_mut() = Method::PUT;
assert_eq!(*request.method(), Method::PUT);

pub fn version(&self) -> Version[src]

Returns the associated version.

pub fn version_mut(&mut self) -> &mut Version[src]

Returns a mutable reference to the associated version.

pub fn set_remote_addr(&mut self, remote_addr: Option<SocketAddr>)[src]

pub fn remote_addr(&self) -> Option<SocketAddr>[src]

pub fn headers(&self) -> &HeaderMap<HeaderValue>[src]

Returns a reference to the associated header field map.

Examples

let request = Request::default();
assert!(request.headers().is_empty());

pub fn headers_mut(&mut self) -> &mut HeaderMap<HeaderValue>[src]

Returns a mutable reference to the associated header field map.

Examples

let mut request: Request = Request::default();
request.headers_mut().insert(HOST, HeaderValue::from_static("world"));
assert!(!request.headers().is_empty());

pub fn get_header<T>(&self, key: &str) -> Option<T> where
    T: FromStr
[src]

Get header with supplied name and try to parse to a ‘T’, return None if failed or not found.

pub fn body(&self) -> Option<&Body>[src]

Returns a reference to the associated HTTP body.

Examples

let request = Request::default();
assert!(request.body().is_some());

pub fn body_mut(&mut self) -> Option<&mut Body>[src]

Returns a mutable reference to the associated HTTP body.

pub fn take_body(&mut self) -> Option<Body>[src]

Take body form the request, and set the body to None in the request.

pub fn extensions(&self) -> &Extensions[src]

Returns a reference to the associated extensions.

Examples

let request = Request::default();
assert!(request.extensions().get::<i32>().is_none());

pub fn extensions_mut(&mut self) -> &mut Extensions[src]

Returns a mutable reference to the associated extensions.

Examples

let mut request: Request = Request::default();
request.extensions_mut().insert("hello");
assert_eq!(request.extensions().get(), Some(&"hello"));

pub fn accept(&self) -> Vec<Mime, Global>[src]

pub fn frist_accept(&self) -> Option<Mime>[src]

pub fn content_type(&self) -> Option<Mime>[src]

pub fn cookies(&self) -> &CookieJar[src]

pub fn cookies_mut(&mut self) -> &mut CookieJar[src]

pub fn params(&self) -> &HashMap<String, String, RandomState>[src]

pub fn params_mut(&mut self) -> &mut HashMap<String, String, RandomState>[src]

pub fn get_param<T>(&self, key: &str) -> Option<T> where
    T: FromStr
[src]

pub fn queries(&self) -> &MultiMap<String, String, RandomState>[src]

pub fn get_query<F>(&self, key: &str) -> Option<F> where
    F: FromStr
[src]

pub async fn get_form<F>(&'_ mut self, key: &'_ str) -> Option<F> where
    F: FromStr
[src]

pub async fn get_file(&'_ mut self, key: &'_ str) -> Option<&'_ FilePart>[src]

pub async fn get_form_or_query<F>(&'_ mut self, key: &'_ str) -> Option<F> where
    F: FromStr
[src]

pub async fn get_query_or_form<F>(&'_ mut self, key: &'_ str) -> Option<F> where
    F: FromStr
[src]

pub async fn payload(&'_ mut self) -> Result<&'_ Vec<u8, Global>, ReadError>[src]

pub async fn form_data(&'_ mut self) -> Result<&'_ FormData, ReadError>[src]

pub async fn read_text(&'_ mut self) -> Result<&'_ str, ReadError>[src]

pub async fn read_from_text<T>(&'_ mut self) -> Result<T, ReadError> where
    T: FromStr
[src]

pub async fn read_from_json<T>(&'_ mut self) -> Result<T, ReadError> where
    T: DeserializeOwned
[src]

pub async fn read_from_form<T>(&'_ mut self) -> Result<T, ReadError> where
    T: DeserializeOwned
[src]

pub async fn read<T>(&'_ mut self) -> Result<T, ReadError> where
    T: DeserializeOwned
[src]

Trait Implementations

impl Debug for Request[src]

impl Default for Request[src]

Auto Trait Implementations

impl !RefUnwindSafe for Request

impl Send for Request

impl Sync for Request

impl Unpin for Request

impl !UnwindSafe for Request

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T> Instrument for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> Same<T> for T

type Output = T

Should always be Self

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

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

The type returned in the event of a conversion error.

impl<V, T> VZip<V> for T where
    V: MultiLane<T>,