[][src]Struct shs::Request

pub struct Request { /* fields omitted */ }

Requirements for the Server Error type parameter. Request type passed to handlers. It provides both the input request and the output response, as well as access to state shared across requests.

Implementations

impl Request[src]

pub fn url(&self) -> &Url[src]

Get the request URL.

pub fn headers(&self) -> &HashMap<UniCase<String>, String>[src]

Get the request headers.

pub fn read_json<'a, D: Deserialize<'a>>(&'a self) -> Result<D, Error>[src]

Deserialize the body as JSON.

pub fn write_bytes(&mut self, body: &[u8])[src]

Write the input as the response body. This also sets the Content-Type to application/octet-stream.

pub fn write_json<S: Serialize>(&mut self, body: &S) -> Result<(), Error>[src]

Serialize the input as the response body. This also sets the Content-Type to application/json.

pub fn write_text(&mut self, body: &str)[src]

Write the input as the response body with utf-8 encoding. This also sets the Content-Type to text/plain; charset=UTF-8.

pub fn set_status(&mut self, status: StatusCode)[src]

Set the response status code.

pub fn set_not_found(&mut self)[src]

Set the response status code to 404 (not found).

pub fn set_header(&mut self, name: &str, value: &str)[src]

Set a response header.

pub fn set_content_type(&mut self, value: &str)[src]

Set the Content-Type response header.

pub fn path_param<F>(&self, name: &str) -> Result<F, Error> where
    F::Err: Error + Send + Sync + 'static,
    F: FromStr
[src]

Get a path parameter. For example, if an input route "/resource/:key" is defined, the handler can get the ":key" portion by calling path_param("key"). The returned type can be anything that implements FromStr.

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, U> Into<U> for T where
    U: From<T>, 
[src]

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.