[][src]Struct tide::Response

pub struct Response { /* fields omitted */ }

An HTTP response

Methods

impl Response[src]

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

Create a new instance.

pub fn with_reader<R>(status: u16, reader: R) -> Self where
    R: BufRead + Unpin + Send + Sync + 'static, 
[src]

Create a new instance from a reader.

pub fn redirect_permanent(location: impl AsRef<str>) -> Self[src]

Creates a response that represents a permanent redirect to location.

Example

async fn route_handler(request: Request<()>) -> tide::Result {
    if let Some(canonical_redirect) = canonicalize(request.uri()) {
        Ok(Response::redirect_permanent(canonical_redirect))
    } else {
         //...
    }
}

pub fn redirect_temporary(location: impl AsRef<str>) -> Self[src]

Creates a response that represents a temporary redirect to location.

Example

async fn route_handler(request: Request<()>) -> tide::Result {
    if let Some(sale_url) = special_sale_today() {
        Ok(Response::redirect_temporary(sale_url))
    } else {
        //...
    }
}

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

Returns the statuscode.

pub fn set_status(self, status: StatusCode) -> Self[src]

Set the statuscode.

pub fn len(&self) -> Option<usize>[src]

Get the length of the body.

pub fn set_header(self, key: HeaderName, value: impl AsRef<str>) -> Self[src]

Insert an HTTP header.

pub fn append_header(self, key: HeaderName, value: impl AsRef<str>) -> Self[src]

Append an HTTP header.

pub fn set_mime(self, mime: Mime) -> Self[src]

Set the request MIME.

Read more on MDN

pub fn body_string(self, string: String) -> Self[src]

Pass a string as the request body.

Mime

The encoding is set to text/plain; charset=utf-8.

pub fn body<R>(self, reader: R) -> Self where
    R: BufRead + Unpin + Send + Sync + 'static, 
[src]

Pass raw bytes as the request body.

Mime

The encoding is set to application/octet-stream.

pub fn set_body(&mut self, body: impl Into<Body>)[src]

Set the body reader.

pub async fn body_form<T: Serialize>(
    __arg0: Self,
    form: T
) -> Result<Response, Error>
[src]

Encode a struct as a form and set as the response body.

Mime

The encoding is set to application/x-www-form-urlencoded.

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

Encode a struct as a form and set as the response body.

Mime

The encoding is set to application/json.

Add cookie to the cookie jar.

Removes the cookie. This instructs the CookiesMiddleware to send a cookie with empty value in the response.

pub fn local<T: Send + Sync + 'static>(&self) -> Option<&T>[src]

Get a local value.

pub fn set_local<T: Send + Sync + 'static>(self, val: T) -> Self[src]

Set a local value.

Trait Implementations

impl Debug for Response[src]

impl<'a> From<&'a str> for Response[src]

impl From<Response> for Response[src]

impl From<String> for Response[src]

impl<State: Send + Sync + 'static> Into<Response> for Request<State>[src]

impl Into<Response> for Response[src]

impl IntoIterator for Response[src]

type Item = (HeaderName, Vec<HeaderValue>)

The type of the elements being iterated over.

type IntoIter = IntoIter

Which kind of iterator are we turning this into?

fn into_iter(self) -> Self::IntoIter[src]

Returns a iterator of references over the remaining items.

impl<'a> IntoIterator for &'a Response[src]

type Item = (&'a HeaderName, &'a Vec<HeaderValue>)

The type of the elements being iterated over.

type IntoIter = Iter<'a>

Which kind of iterator are we turning this into?

impl<'a> IntoIterator for &'a mut Response[src]

type Item = (&'a HeaderName, &'a mut Vec<HeaderValue>)

The type of the elements being iterated over.

type IntoIter = IterMut<'a>

Which kind of iterator are we turning this into?

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

impl<I> IntoIterator for I where
    I: Iterator
[src]

type Item = <I as Iterator>::Item

The type of the elements being iterated over.

type IntoIter = I

Which kind of iterator are we turning this into?

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.