pub struct Response<B> { /* private fields */ }
Expand description
An HTTP response.
Implementations
sourceimpl Response<BoxBody>
impl Response<BoxBody>
sourcepub fn new(status: StatusCode) -> Response<BoxBody>
pub fn new(status: StatusCode) -> Response<BoxBody>
Constructs a new response with default body.
sourcepub fn build(status: StatusCode) -> ResponseBuilder
pub fn build(status: StatusCode) -> ResponseBuilder
Constructs a new response builder.
sourcepub fn bad_request() -> Response<BoxBody>
pub fn bad_request() -> Response<BoxBody>
Constructs a new response with status 400 Bad Request.
sourcepub fn internal_server_error() -> Response<BoxBody>
pub fn internal_server_error() -> Response<BoxBody>
Constructs a new response with status 500 Internal Server Error.
sourceimpl<B> Response<B>
impl<B> Response<B>
sourcepub fn with_body(status: StatusCode, body: B) -> Response<B>
pub fn with_body(status: StatusCode, body: B) -> Response<B>
Constructs a new response with given body.
sourcepub fn head(&self) -> &ResponseHead
pub fn head(&self) -> &ResponseHead
Returns a reference to the head of this response.
sourcepub fn head_mut(&mut self) -> &mut ResponseHead
pub fn head_mut(&mut self) -> &mut ResponseHead
Returns a mutable reference to the head of this response.
sourcepub fn status(&self) -> StatusCode
pub fn status(&self) -> StatusCode
Returns the status code of this response.
sourcepub fn status_mut(&mut self) -> &mut StatusCode
pub fn status_mut(&mut self) -> &mut StatusCode
Returns a mutable reference the status code of this response.
sourcepub fn headers_mut(&mut self) -> &mut HeaderMap
pub fn headers_mut(&mut self) -> &mut HeaderMap
Returns a mutable reference to response headers.
sourcepub fn keep_alive(&self) -> bool
pub fn keep_alive(&self) -> bool
Returns true if keep-alive is enabled.
sourcepub fn extensions(&self) -> Ref<'_, Extensions>
pub fn extensions(&self) -> Ref<'_, Extensions>
Returns a reference to the extensions of this response.
sourcepub fn extensions_mut(&mut self) -> RefMut<'_, Extensions>
pub fn extensions_mut(&mut self) -> RefMut<'_, Extensions>
Returns a mutable reference to the extensions of this response.
sourcepub fn into_parts(self) -> (Response<()>, B)
pub fn into_parts(self) -> (Response<()>, B)
Returns split head and body.
Implementation Notes
Due to internal performance optimizations, the first element of the returned tuple is a
Response
as well but only contains the head of the response this was called on.
sourcepub fn map_body<F, B2>(self, f: F) -> Response<B2> where
F: FnOnce(&mut ResponseHead, B) -> B2,
pub fn map_body<F, B2>(self, f: F) -> Response<B2> where
F: FnOnce(&mut ResponseHead, B) -> B2,
Returns new response with mapped body.
pub fn map_into_boxed_body(self) -> Response<BoxBody> where
B: 'static + MessageBody,
Trait Implementations
sourceimpl<B> BodyEncoding for Response<B>
impl<B> BodyEncoding for Response<B>
sourcefn get_encoding(&self) -> Option<ContentEncoding>
fn get_encoding(&self) -> Option<ContentEncoding>
Get content encoding
sourcefn encoding(&mut self, encoding: ContentEncoding) -> &mut Self
fn encoding(&mut self, encoding: ContentEncoding) -> &mut Self
Set content encoding Read more
sourceimpl<B> Debug for Response<B> where
B: MessageBody,
impl<B> Debug for Response<B> where
B: MessageBody,
sourceimpl<'_> From<&HandshakeError> for Response<BoxBody>
impl<'_> From<&HandshakeError> for Response<BoxBody>
sourcefn from(err: &HandshakeError) -> Response<BoxBody>
fn from(err: &HandshakeError) -> Response<BoxBody>
Converts to this type from the input type.
sourceimpl From<ByteString> for Response<ByteString>
impl From<ByteString> for Response<ByteString>
sourcefn from(val: ByteString) -> Response<ByteString>
fn from(val: ByteString) -> Response<ByteString>
Converts to this type from the input type.
sourceimpl<E, U, I> From<DispatcherError<E, U, I>> for Response<BoxBody> where
E: Debug + Display,
U: Encoder<I> + Decoder,
<U as Encoder<I>>::Error: Debug,
<U as Decoder>::Error: Debug,
impl<E, U, I> From<DispatcherError<E, U, I>> for Response<BoxBody> where
E: Debug + Display,
U: Encoder<I> + Decoder,
<U as Encoder<I>>::Error: Debug,
<U as Decoder>::Error: Debug,
sourceimpl From<HandshakeError> for Response<BoxBody>
impl From<HandshakeError> for Response<BoxBody>
sourcefn from(err: HandshakeError) -> Response<BoxBody>
fn from(err: HandshakeError) -> Response<BoxBody>
Converts to this type from the input type.
sourceimpl<B> From<HttpResponse<B>> for Response<B>
impl<B> From<HttpResponse<B>> for Response<B>
sourcefn from(res: HttpResponse<B>) -> Self
fn from(res: HttpResponse<B>) -> Self
Converts to this type from the input type.
sourceimpl From<HttpResponseBuilder> for Response<BoxBody>
impl From<HttpResponseBuilder> for Response<BoxBody>
sourcefn from(builder: HttpResponseBuilder) -> Self
fn from(builder: HttpResponseBuilder) -> Self
Converts to this type from the input type.
sourceimpl From<Infallible> for Response<BoxBody>
impl From<Infallible> for Response<BoxBody>
sourcefn from(val: Infallible) -> Response<BoxBody>
fn from(val: Infallible) -> Response<BoxBody>
Converts to this type from the input type.
sourceimpl From<ParseError> for Response<BoxBody>
impl From<ParseError> for Response<BoxBody>
sourcefn from(err: ParseError) -> Response<BoxBody>
fn from(err: ParseError) -> Response<BoxBody>
Converts to this type from the input type.
sourceimpl<B> From<Response<B>> for HttpResponse<B>
impl<B> From<Response<B>> for HttpResponse<B>
sourceimpl From<Response<BoxBody>> for DispatchError
impl From<Response<BoxBody>> for DispatchError
sourcefn from(original: Response<BoxBody>) -> DispatchError
fn from(original: Response<BoxBody>) -> DispatchError
Converts to this type from the input type.
sourceimpl From<ResponseBuilder> for Response<BoxBody>
impl From<ResponseBuilder> for Response<BoxBody>
sourcefn from(builder: ResponseBuilder) -> Response<BoxBody>
fn from(builder: ResponseBuilder) -> Response<BoxBody>
Converts to this type from the input type.
sourceimpl<I, E> From<Result<I, E>> for Response<BoxBody> where
I: Into<Response<BoxBody>>,
E: Into<Error>,
impl<I, E> From<Result<I, E>> for Response<BoxBody> where
I: Into<Response<BoxBody>>,
E: Into<Error>,
sourceimpl<B> From<ServiceResponse<B>> for Response<B>
impl<B> From<ServiceResponse<B>> for Response<B>
sourcefn from(res: ServiceResponse<B>) -> Response<B>
fn from(res: ServiceResponse<B>) -> Response<B>
Converts to this type from the input type.
sourceimpl Responder for Response<BoxBody>
impl Responder for Response<BoxBody>
type Body = BoxBody
sourcefn respond_to(self, _: &HttpRequest) -> HttpResponse<Self::Body>ⓘNotable traits for HttpResponse<BoxBody>impl Future for HttpResponse<BoxBody> type Output = Result<Response<BoxBody>, Error>;
fn respond_to(self, _: &HttpRequest) -> HttpResponse<Self::Body>ⓘNotable traits for HttpResponse<BoxBody>impl Future for HttpResponse<BoxBody> type Output = Result<Response<BoxBody>, Error>;
Convert self to HttpResponse
.
sourcefn customize(self) -> CustomizeResponder<Self> where
Self: Sized,
fn customize(self) -> CustomizeResponder<Self> where
Self: Sized,
Wraps responder to allow alteration of its response. Read more
Auto Trait Implementations
impl<B> !RefUnwindSafe for Response<B>
impl<B> !Send for Response<B>
impl<B> !Sync for Response<B>
impl<B> Unpin for Response<B> where
B: Unpin,
impl<B> !UnwindSafe for Response<B>
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
sourceimpl<T> Instrument for T
impl<T> Instrument for T
sourcefn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
sourcefn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
sourceimpl<T> WithSubscriber for T
impl<T> WithSubscriber for T
sourcefn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> where
S: Into<Dispatch>,
fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> where
S: Into<Dispatch>,
Attaches the provided Subscriber
to this type, returning a
WithDispatch
wrapper. Read more
sourcefn with_current_subscriber(self) -> WithDispatch<Self>
fn with_current_subscriber(self) -> WithDispatch<Self>
Attaches the current default Subscriber
to this type, returning a
WithDispatch
wrapper. Read more