Struct highnoon::response::Response[][src]

pub struct Response { /* fields omitted */ }

A response to be returned to the client. You do not always need to use this struct directly as endpoints can return anything implementing Responder. However this is the most flexible way to construct a reply, and it implements Responder (the "identity" implementation).

Implementations

impl Response[src]

pub fn ok() -> Self[src]

Create an empty response with status code OK (200)

pub fn status(s: StatusCode) -> Self[src]

Create an empty response with the given status code

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

Set the status code of a response

pub fn get_status(&self) -> StatusCode[src]

Get the status code of a response

pub fn body(self, body: impl Into<Body>) -> Self[src]

Set the body of the response

pub fn reader(self, r: impl AsyncRead + Send + 'static) -> Self[src]

Set the body to an AsyncRead object

pub async fn path(self, path: impl AsRef<Path>) -> Result<Self>[src]

Set the body to the content of a file given by a Path Also sets a content type by guessing the mime type from the path name

pub fn json(self, body: impl Serialize) -> Result<Self>[src]

Set the body of the response to a JSON payload

pub fn form(self, body: impl Serialize) -> Result<Self>[src]

Set the body of the response to form data

pub fn header<H: Header>(self, h: H) -> Self[src]

Set a header (from the headers crate)

pub fn set_header<H: Header>(&mut self, h: H)[src]

Set a header (without consuming self - useful outside of method chains)

pub fn raw_header(
    self,
    name: impl Into<HeaderName>,
    key: impl Into<HeaderValue>
) -> Self
[src]

Set a raw header (from the http crate)

pub fn into_inner(self) -> Response<Body>[src]

Consume this response and return the inner hyper::Response

Trait Implementations

impl AsRef<Response<Body>> for Response[src]

Get a reference to the inner hyper::Response

impl Debug for Response[src]

impl From<Response<Body>> for Response[src]

Create a Response from a hyper::Response<hyper::Body>

impl Responder for Response[src]

Identity implementation

Auto Trait Implementations

impl !RefUnwindSafe for Response

impl Send for Response

impl Sync for Response

impl Unpin for Response

impl !UnwindSafe for Response

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> 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>,