[−][src]Struct tide::Response
An HTTP response
Implementations
impl Response
[src]
#[must_use]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]
R: BufRead + Unpin + Send + Sync + 'static,
Create a new instance from a reader.
pub fn redirect(location: impl AsRef<str>) -> Self
[src]
Creates a response that represents a redirect to location
.
Uses status code 302 Found.
Example
async fn route_handler(request: Request<()>) -> tide::Result { if let Some(sale_url) = special_sale_today() { Ok(Response::redirect(sale_url)) } else { //... } }
#[must_use]pub fn status(&self) -> StatusCode
[src]
Returns the statuscode.
#[must_use]pub fn set_status(self, status: StatusCode) -> Self
[src]
Set the statuscode.
#[must_use]pub fn len(&self) -> Option<usize>
[src]
Get the length of the body.
#[must_use]pub fn is_empty(&self) -> Option<bool>
[src]
Checks if the body is empty.
#[must_use]pub fn header(&self, name: impl Into<HeaderName>) -> Option<&HeaderValues>
[src]
Get an HTTP header.
pub fn remove_header(
&mut self,
name: impl Into<HeaderName>
) -> Option<HeaderValues>
[src]
&mut self,
name: impl Into<HeaderName>
) -> Option<HeaderValues>
Remove a header.
pub fn set_header(
self,
key: impl Into<HeaderName>,
value: impl ToHeaderValues
) -> Self
[src]
self,
key: impl Into<HeaderName>,
value: impl ToHeaderValues
) -> Self
Insert an HTTP header.
pub fn append_header(
self,
key: impl Into<HeaderName>,
value: impl ToHeaderValues
) -> Self
[src]
self,
key: impl Into<HeaderName>,
value: impl ToHeaderValues
) -> Self
Append an HTTP header.
#[must_use]pub fn set_mime(self, mime: Mime) -> Self
[src]
Set the request MIME.
#[must_use]pub fn body_string(self, string: String) -> Self
[src]
pub fn body<R>(self, reader: R) -> Self where
R: BufRead + Unpin + Send + Sync + 'static,
[src]
R: BufRead + Unpin + Send + Sync + 'static,
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<Self, Error>
[src]
__arg0: Self,
form: T
) -> Result<Self, Error>
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
.
pub fn take_body(&mut self) -> Body
[src]
Take the request body, replacing it with an empty body.
pub fn set_cookie(&mut self, cookie: Cookie<'static>)
[src]
Add cookie to the cookie jar.
pub fn remove_cookie(&mut self, cookie: Cookie<'static>)
[src]
Removes the cookie. This instructs the CookiesMiddleware
to send a cookie with empty value
in the response.
#[must_use]pub fn ext<T: Send + Sync + 'static>(&self) -> Option<&T>
[src]
Get a response extension value.
pub fn set_ext<T: Send + Sync + 'static>(self, val: T) -> Self
[src]
Set a local value.
pub fn from_res<T>(value: T) -> Self where
T: Into<Response>,
[src]
T: Into<Response>,
Create a tide::Response
from a type that can be converted into an
http_types::Response
.
Trait Implementations
impl AsMut<Response> for Response
[src]
impl AsRef<Response> for Response
[src]
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<'_> Index<&'_ str> for Response
[src]
type Output = HeaderValues
The returned type after indexing.
fn index(&self, name: &str) -> &HeaderValues
[src]
Returns a reference to the value corresponding to the supplied name.
Panics
Panics if the name is not present in Response
.
impl Index<HeaderName> for Response
[src]
type Output = HeaderValues
The returned type after indexing.
fn index(&self, name: HeaderName) -> &HeaderValues
[src]
Returns a reference to the value corresponding to the supplied name.
Panics
Panics if the name is not present in Response
.
impl<T: AsRef<str>> Into<Response> for Redirect<T>
[src]
impl<'_, T: AsRef<str>> Into<Response> for &'_ Redirect<T>
[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, HeaderValues)
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 HeaderValues)
The type of the elements being iterated over.
type IntoIter = Iter<'a>
Which kind of iterator are we turning this into?
fn into_iter(self) -> Self::IntoIter
[src]
impl<'a> IntoIterator for &'a mut Response
[src]
type Item = (&'a HeaderName, &'a mut HeaderValues)
The type of the elements being iterated over.
type IntoIter = IterMut<'a>
Which kind of iterator are we turning this into?
fn into_iter(self) -> Self::IntoIter
[src]
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]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<I> IntoIterator for I where
I: Iterator,
[src]
I: Iterator,
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?
fn into_iter(self) -> I
[src]
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,