Struct ntex::web::WebResponse
source · pub struct WebResponse { /* private fields */ }
Expand description
An service http response
Implementations§
source§impl WebResponse
impl WebResponse
sourcepub fn new(response: Response<Body>, request: HttpRequest) -> Self
pub fn new(response: Response<Body>, request: HttpRequest) -> Self
Create web response instance
sourcepub fn from_err<Err: ErrorRenderer, E: Into<Err::Container>>(
err: E,
request: HttpRequest
) -> Self
pub fn from_err<Err: ErrorRenderer, E: Into<Err::Container>>( err: E, request: HttpRequest ) -> Self
Create web response from the error
sourcepub fn error_response<Err: ErrorRenderer, E: Into<Err::Container>>(
self,
err: E
) -> Self
pub fn error_response<Err: ErrorRenderer, E: Into<Err::Container>>( self, err: E ) -> Self
Create web response for error
sourcepub fn into_response(self, response: Response) -> WebResponse
pub fn into_response(self, response: Response) -> WebResponse
Create web response
sourcepub fn request(&self) -> &HttpRequest
pub fn request(&self) -> &HttpRequest
Get reference to original request
sourcepub fn response_mut(&mut self) -> &mut Response<Body>
pub fn response_mut(&mut self) -> &mut Response<Body>
Get mutable reference to response
sourcepub fn status(&self) -> StatusCode
pub fn status(&self) -> StatusCode
Get the response status code
sourcepub fn headers_mut(&mut self) -> &mut HeaderMap
pub fn headers_mut(&mut self) -> &mut HeaderMap
Returns mutable response’s headers.
sourcepub fn checked_expr<Err, F, E>(self, f: F) -> Selfwhere
F: FnOnce(&mut Self) -> Result<(), E>,
E: Into<Err::Container>,
Err: ErrorRenderer,
pub fn checked_expr<Err, F, E>(self, f: F) -> Selfwhere F: FnOnce(&mut Self) -> Result<(), E>, E: Into<Err::Container>, Err: ErrorRenderer,
Execute closure and in case of error convert it to response.
sourcepub fn take_body(&mut self) -> ResponseBody<Body>
pub fn take_body(&mut self) -> ResponseBody<Body>
Extract response body
sourcepub fn map_body<F>(self, f: F) -> WebResponsewhere
F: FnOnce(&mut ResponseHead, ResponseBody<Body>) -> ResponseBody<Body>,
pub fn map_body<F>(self, f: F) -> WebResponsewhere F: FnOnce(&mut ResponseHead, ResponseBody<Body>) -> ResponseBody<Body>,
Set a new body
Trait Implementations§
source§impl Debug for WebResponse
impl Debug for WebResponse
Auto Trait Implementations§
impl !RefUnwindSafe for WebResponse
impl !Send for WebResponse
impl !Sync for WebResponse
impl Unpin for WebResponse
impl !UnwindSafe for WebResponse
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more