Struct arc_reactor::prelude::Response [−][src]
pub struct Response { /* fields omitted */ }
Methods
impl Response
[src]
impl Response
pub fn new() -> Self
[src]
pub fn new() -> Self
pub fn version(&self) -> Version
[src]
pub fn version(&self) -> Version
Get the HTTP version of this response.
pub fn headers(&self) -> &HeaderMap<HeaderValue>
[src]
pub fn headers(&self) -> &HeaderMap<HeaderValue>
Get the headers from the response.
pub fn headers_mut(&mut self) -> &mut HeaderMap<HeaderValue>
[src]
pub fn headers_mut(&mut self) -> &mut HeaderMap<HeaderValue>
Get a mutable reference to the headers.
pub fn status(&self) -> StatusCode
[src]
pub fn status(&self) -> StatusCode
Get the status from the server.
pub fn status_mut(&mut self) -> &mut StatusCode
[src]
pub fn status_mut(&mut self) -> &mut StatusCode
pub fn set_status(&mut self, status: u16)
[src]
pub fn set_status(&mut self, status: u16)
Set the StatusCode
for this response.
Example
pub fn get_profile(req: Request, res: Response) { // performed task on request // return an 401 response res.set_status(401); }
pub fn with_status(self, status: u16) -> Self
[src]
pub fn with_status(self, status: u16) -> Self
Set the status and move the Response.
Useful for the "builder-style" pattern.
pub fn text<T: Into<String>>(&mut self, body: T)
[src]
pub fn text<T: Into<String>>(&mut self, body: T)
Set a text/plain response.
pub fn with_text<T: Into<String>>(self, body: T) -> Self
[src]
pub fn with_text<T: Into<String>>(self, body: T) -> Self
set a text/plain response moves the response
useful for builder-style
pub fn get<T: Send + Sync + 'static>(&self) -> Option<&T>
[src]
pub fn get<T: Send + Sync + 'static>(&self) -> Option<&T>
get a reference to a type previously set on the response
pub fn set<T: Send + Sync + 'static>(&mut self, value: T) -> Option<T>
[src]
pub fn set<T: Send + Sync + 'static>(&mut self, value: T) -> Option<T>
Set a type on the response.
pub fn remove<T: Send + Sync + 'static>(&mut self) -> Option<T>
[src]
pub fn remove<T: Send + Sync + 'static>(&mut self) -> Option<T>
Removes the type previously set on the response.
pub fn with_file<P>(
self,
pathbuf: P
) -> impl Future<Item = Response, Error = Response> where
P: AsRef<Path> + Send + Clone + Debug + 'static,
[src]
pub fn with_file<P>(
self,
pathbuf: P
) -> impl Future<Item = Response, Error = Response> where
P: AsRef<Path> + Send + Clone + Debug + 'static,
Respond with a file. this method will set the appropriate Content-type and Content-Length headers unfortunately, this doesn't support byte ranges, yet. The file is streamed asynchronously from the filesystem to the client with the Content-Encoding: chunked.
pub fn with_body<T: Into<Body>>(self, body: T) -> Self
[src]
pub fn with_body<T: Into<Body>>(self, body: T) -> Self
Set the body and move the Response.
Useful for the "builder-style" pattern.
pub fn set_body<T: Into<Body>>(&mut self, body: T)
[src]
pub fn set_body<T: Into<Body>>(&mut self, body: T)
pub fn body_ref(&self) -> &Body
[src]
pub fn body_ref(&self) -> &Body
Read the body.
pub fn body(self) -> Body
[src]
pub fn body(self) -> Body
Take the Body
of this response.
pub fn redirect(self, url: &'static str) -> Response
[src]
pub fn redirect(self, url: &'static str) -> Response
Set a HTTP redirect on the response header
Set the status code 401 on the response
pub fn badRequest(self) -> Self
[src]
pub fn badRequest(self) -> Self
Set the status code 400 on the response
pub fn forbidden(self) -> Self
[src]
pub fn forbidden(self) -> Self
Set the status code 403 on the response
pub fn methodNotAllowed(self) -> Self
[src]
pub fn methodNotAllowed(self) -> Self
Set the status code 405 on the response
pub fn notAcceptable(self) -> Self
[src]
pub fn notAcceptable(self) -> Self
Set the status code 406 on the response
pub fn requestTimeout(self) -> Self
[src]
pub fn requestTimeout(self) -> Self
Set the status code 408 on the response
pub fn internalServerError(self) -> Self
[src]
pub fn internalServerError(self) -> Self
Set the status code 500 on the response
pub fn badGateway(self) -> Self
[src]
pub fn badGateway(self) -> Self
Set the status code 502 on the response
Set the status code 503 on the response
Trait Implementations
impl<T: Serialize> From<(u16, T)> for Response
[src]
impl<T: Serialize> From<(u16, T)> for Response
impl From<Response> for Response<Body>
[src]
impl From<Response> for Response<Body>
impl From<JsonError> for Response
[src]
impl From<JsonError> for Response
impl From<QueryParseError> for Response
[src]
impl From<QueryParseError> for Response
fn from(error: QueryParseError) -> Response
[src]
fn from(error: QueryParseError) -> Response
Performs the conversion.
impl<T> MiddleWare<Response> for T where
T: Fn(Response) -> MiddleWareFuture<Response> + Send + Sync + Clone + 'static,
[src]
impl<T> MiddleWare<Response> for T where
T: Fn(Response) -> MiddleWareFuture<Response> + Send + Sync + Clone + 'static,
fn call(&self, res: Response) -> MiddleWareFuture<Response>
[src]
fn call(&self, res: Response) -> MiddleWareFuture<Response>
impl MiddleWare<Response> for Vec<Box<MiddleWare<Response>>>
[src]
impl MiddleWare<Response> for Vec<Box<MiddleWare<Response>>>
This enables a vector of MiddleWare<Request>
to behave like a single
MiddleWare<Request>
returning Err(Response)
in any of the
MiddleWare<Request>
will cause the rest of the middlewares to be skipped.
Note that there's a conveinient macro mw
that allows you not write
boxes everywhere.
fn call(&self, response: Response) -> MiddleWareFuture<Response>
[src]
fn call(&self, response: Response) -> MiddleWareFuture<Response>
impl MiddleWare<Response> for Box<MiddleWare<Response>>
[src]
impl MiddleWare<Response> for Box<MiddleWare<Response>>
fn call(&self, item: Response) -> MiddleWareFuture<Response>
[src]
fn call(&self, item: Response) -> MiddleWareFuture<Response>
impl Debug for Response
[src]
impl Debug for Response
fn fmt(&self, f: &mut Formatter) -> Result
[src]
fn fmt(&self, f: &mut Formatter) -> Result
Formats the value using the given formatter. Read more
impl Default for Response
[src]
impl Default for Response