Struct actix_web::dev::ServiceResponse
source · pub struct ServiceResponse<B = BoxBody> { /* private fields */ }
Expand description
A service level response wrapper.
Implementations§
source§impl ServiceResponse<BoxBody>
impl ServiceResponse<BoxBody>
sourcepub fn from_err<E: Into<Error>>(err: E, request: HttpRequest) -> Self
pub fn from_err<E: Into<Error>>(err: E, request: HttpRequest) -> Self
Create service response from the error
source§impl<B> ServiceResponse<B>
impl<B> ServiceResponse<B>
sourcepub fn new(request: HttpRequest, response: HttpResponse<B>) -> Self
pub fn new(request: HttpRequest, response: HttpResponse<B>) -> Self
Create service response instance
sourcepub fn error_response<E: Into<Error>>(self, err: E) -> ServiceResponse
pub fn error_response<E: Into<Error>>(self, err: E) -> ServiceResponse
Create service response for error
sourcepub fn into_response<B1>(
self,
response: HttpResponse<B1>
) -> ServiceResponse<B1>
pub fn into_response<B1>( self, response: HttpResponse<B1> ) -> ServiceResponse<B1>
Create service response
sourcepub fn request(&self) -> &HttpRequest
pub fn request(&self) -> &HttpRequest
Returns reference to original request.
sourcepub fn response(&self) -> &HttpResponse<B>
pub fn response(&self) -> &HttpResponse<B>
Returns reference to response.
sourcepub fn response_mut(&mut self) -> &mut HttpResponse<B>
pub fn response_mut(&mut self) -> &mut HttpResponse<B>
Returns mutable reference to response.
sourcepub fn status(&self) -> StatusCode
pub fn status(&self) -> StatusCode
Returns 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 into_parts(self) -> (HttpRequest, HttpResponse<B>)
pub fn into_parts(self) -> (HttpRequest, HttpResponse<B>)
Destructures ServiceResponse
into request and response components.
sourcepub fn map_body<F, B2>(self, f: F) -> ServiceResponse<B2>where
F: FnOnce(&mut ResponseHead, B) -> B2,
pub fn map_body<F, B2>(self, f: F) -> ServiceResponse<B2>where F: FnOnce(&mut ResponseHead, B) -> B2,
Map the current body type to another using a closure. Returns a new response.
Closure receives the response head and the current body type.
pub fn map_into_left_body<R>(self) -> ServiceResponse<EitherBody<B, R>>
pub fn map_into_right_body<L>(self) -> ServiceResponse<EitherBody<L, B>>
pub fn map_into_boxed_body(self) -> ServiceResponse<BoxBody>where B: MessageBody + 'static,
Trait Implementations§
source§impl<B> Debug for ServiceResponse<B>where
B: MessageBody,
B::Error: Into<Error>,
impl<B> Debug for ServiceResponse<B>where B: MessageBody, B::Error: Into<Error>,
source§impl<B> From<ServiceResponse<B>> for HttpResponse<B>
impl<B> From<ServiceResponse<B>> for HttpResponse<B>
source§fn from(res: ServiceResponse<B>) -> HttpResponse<B>
fn from(res: ServiceResponse<B>) -> HttpResponse<B>
Converts to this type from the input type.
source§impl<B> From<ServiceResponse<B>> for Response<B>
impl<B> From<ServiceResponse<B>> for Response<B>
source§fn from(res: ServiceResponse<B>) -> Response<B>
fn from(res: ServiceResponse<B>) -> Response<B>
Converts to this type from the input type.
Auto Trait Implementations§
impl<B = BoxBody> !RefUnwindSafe for ServiceResponse<B>
impl<B = BoxBody> !Send for ServiceResponse<B>
impl<B = BoxBody> !Sync for ServiceResponse<B>
impl<B> Unpin for ServiceResponse<B>where B: Unpin,
impl<B = BoxBody> !UnwindSafe for ServiceResponse<B>
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