[−][src]Trait actix_web::Responder
Trait implemented by types that can be converted to a http response.
Types that implement this trait can be used as the return type of a handler.
Associated Types
type Error: Into<Error>
The associated error which can be returned.
type Future: IntoFuture<Item = Response, Error = Self::Error>
The future response value.
Required methods
fn respond_to(self, req: &HttpRequest) -> Self::Future
Convert itself to AsyncResult
or Error
.
Provided methods
fn with_status(self, status: StatusCode) -> CustomResponder<Self> where
Self: Sized,
Self: Sized,
Override a status code for a Responder.
use actix_web::{HttpRequest, Responder, http::StatusCode}; fn index(req: HttpRequest) -> impl Responder { "Welcome!".with_status(StatusCode::OK) }
fn with_header<K, V>(self, key: K, value: V) -> CustomResponder<Self> where
Self: Sized,
HeaderName: HttpTryFrom<K>,
V: IntoHeaderValue,
Self: Sized,
HeaderName: HttpTryFrom<K>,
V: IntoHeaderValue,
Add header to the Responder's response.
use actix_web::{web, HttpRequest, Responder}; use serde::Serialize; #[derive(Serialize)] struct MyObj { name: String, } fn index(req: HttpRequest) -> impl Responder { web::Json( MyObj{name: "Name".to_string()} ) .with_header("x-version", "1.2.3") }
Implementations on Foreign Types
impl<T> Responder for Option<T> where
T: Responder,
[src]
T: Responder,
type Error = T::Error
type Future = EitherFuture<<T::Future as IntoFuture>::Future, FutureResult<Response, T::Error>>
fn respond_to(self, req: &HttpRequest) -> Self::Future
[src]
fn with_status(self, status: StatusCode) -> CustomResponder<Self> where
Self: Sized,
[src]
Self: Sized,
fn with_header<K, V>(self, key: K, value: V) -> CustomResponder<Self> where
Self: Sized,
HeaderName: HttpTryFrom<K>,
V: IntoHeaderValue,
[src]
Self: Sized,
HeaderName: HttpTryFrom<K>,
V: IntoHeaderValue,
impl<T, E> Responder for Result<T, E> where
T: Responder,
E: Into<Error>,
[src]
T: Responder,
E: Into<Error>,
type Error = Error
type Future = EitherFuture<ResponseFuture<<T::Future as IntoFuture>::Future>, FutureResult<Response, Error>>
fn respond_to(self, req: &HttpRequest) -> Self::Future
[src]
fn with_status(self, status: StatusCode) -> CustomResponder<Self> where
Self: Sized,
[src]
Self: Sized,
fn with_header<K, V>(self, key: K, value: V) -> CustomResponder<Self> where
Self: Sized,
HeaderName: HttpTryFrom<K>,
V: IntoHeaderValue,
[src]
Self: Sized,
HeaderName: HttpTryFrom<K>,
V: IntoHeaderValue,
impl Responder for ()
[src]
type Error = Error
type Future = FutureResult<Response, Error>
fn respond_to(self, _: &HttpRequest) -> Self::Future
[src]
fn with_status(self, status: StatusCode) -> CustomResponder<Self> where
Self: Sized,
[src]
Self: Sized,
fn with_header<K, V>(self, key: K, value: V) -> CustomResponder<Self> where
Self: Sized,
HeaderName: HttpTryFrom<K>,
V: IntoHeaderValue,
[src]
Self: Sized,
HeaderName: HttpTryFrom<K>,
V: IntoHeaderValue,
impl Responder for &'static str
[src]
type Error = Error
type Future = FutureResult<Response, Error>
fn respond_to(self, _: &HttpRequest) -> Self::Future
[src]
fn with_status(self, status: StatusCode) -> CustomResponder<Self> where
Self: Sized,
[src]
Self: Sized,
fn with_header<K, V>(self, key: K, value: V) -> CustomResponder<Self> where
Self: Sized,
HeaderName: HttpTryFrom<K>,
V: IntoHeaderValue,
[src]
Self: Sized,
HeaderName: HttpTryFrom<K>,
V: IntoHeaderValue,
impl Responder for &'static [u8]
[src]
type Error = Error
type Future = FutureResult<Response, Error>
fn respond_to(self, _: &HttpRequest) -> Self::Future
[src]
fn with_status(self, status: StatusCode) -> CustomResponder<Self> where
Self: Sized,
[src]
Self: Sized,
fn with_header<K, V>(self, key: K, value: V) -> CustomResponder<Self> where
Self: Sized,
HeaderName: HttpTryFrom<K>,
V: IntoHeaderValue,
[src]
Self: Sized,
HeaderName: HttpTryFrom<K>,
V: IntoHeaderValue,
impl Responder for String
[src]
type Error = Error
type Future = FutureResult<Response, Error>
fn respond_to(self, _: &HttpRequest) -> Self::Future
[src]
fn with_status(self, status: StatusCode) -> CustomResponder<Self> where
Self: Sized,
[src]
Self: Sized,
fn with_header<K, V>(self, key: K, value: V) -> CustomResponder<Self> where
Self: Sized,
HeaderName: HttpTryFrom<K>,
V: IntoHeaderValue,
[src]
Self: Sized,
HeaderName: HttpTryFrom<K>,
V: IntoHeaderValue,
impl<'a> Responder for &'a String
[src]
type Error = Error
type Future = FutureResult<Response, Error>
fn respond_to(self, _: &HttpRequest) -> Self::Future
[src]
fn with_status(self, status: StatusCode) -> CustomResponder<Self> where
Self: Sized,
[src]
Self: Sized,
fn with_header<K, V>(self, key: K, value: V) -> CustomResponder<Self> where
Self: Sized,
HeaderName: HttpTryFrom<K>,
V: IntoHeaderValue,
[src]
Self: Sized,
HeaderName: HttpTryFrom<K>,
V: IntoHeaderValue,
impl<I, E> Responder for Box<dyn Future<Item = I, Error = E>> where
I: Responder + 'static,
E: Into<Error> + 'static,
[src]
I: Responder + 'static,
E: Into<Error> + 'static,
type Error = Error
type Future = Box<dyn Future<Item = Response, Error = Error>>
fn respond_to(self, req: &HttpRequest) -> Self::Future
[src]
fn with_status(self, status: StatusCode) -> CustomResponder<Self> where
Self: Sized,
[src]
Self: Sized,
fn with_header<K, V>(self, key: K, value: V) -> CustomResponder<Self> where
Self: Sized,
HeaderName: HttpTryFrom<K>,
V: IntoHeaderValue,
[src]
Self: Sized,
HeaderName: HttpTryFrom<K>,
V: IntoHeaderValue,
Implementors
impl Responder for ResponseBuilder
[src]
type Error = Error
type Future = FutureResult<Response, Error>
fn respond_to(self, _: &HttpRequest) -> Self::Future
[src]
fn with_status(self, status: StatusCode) -> CustomResponder<Self> where
Self: Sized,
[src]
Self: Sized,
fn with_header<K, V>(self, key: K, value: V) -> CustomResponder<Self> where
Self: Sized,
HeaderName: HttpTryFrom<K>,
V: IntoHeaderValue,
[src]
Self: Sized,
HeaderName: HttpTryFrom<K>,
V: IntoHeaderValue,
impl Responder for Bytes
[src]
type Error = Error
type Future = FutureResult<Response, Error>
fn respond_to(self, _: &HttpRequest) -> Self::Future
[src]
fn with_status(self, status: StatusCode) -> CustomResponder<Self> where
Self: Sized,
[src]
Self: Sized,
fn with_header<K, V>(self, key: K, value: V) -> CustomResponder<Self> where
Self: Sized,
HeaderName: HttpTryFrom<K>,
V: IntoHeaderValue,
[src]
Self: Sized,
HeaderName: HttpTryFrom<K>,
V: IntoHeaderValue,
impl Responder for BytesMut
[src]
type Error = Error
type Future = FutureResult<Response, Error>
fn respond_to(self, _: &HttpRequest) -> Self::Future
[src]
fn with_status(self, status: StatusCode) -> CustomResponder<Self> where
Self: Sized,
[src]
Self: Sized,
fn with_header<K, V>(self, key: K, value: V) -> CustomResponder<Self> where
Self: Sized,
HeaderName: HttpTryFrom<K>,
V: IntoHeaderValue,
[src]
Self: Sized,
HeaderName: HttpTryFrom<K>,
V: IntoHeaderValue,
impl Responder for Response
[src]
type Error = Error
type Future = FutureResult<Response, Error>
fn respond_to(self, _: &HttpRequest) -> Self::Future
[src]
fn with_status(self, status: StatusCode) -> CustomResponder<Self> where
Self: Sized,
[src]
Self: Sized,
fn with_header<K, V>(self, key: K, value: V) -> CustomResponder<Self> where
Self: Sized,
HeaderName: HttpTryFrom<K>,
V: IntoHeaderValue,
[src]
Self: Sized,
HeaderName: HttpTryFrom<K>,
V: IntoHeaderValue,
impl<A, B> Responder for Either<A, B> where
A: Responder,
B: Responder,
[src]
A: Responder,
B: Responder,
type Error = Error
type Future = EitherResponder<<A::Future as IntoFuture>::Future, <B::Future as IntoFuture>::Future>
fn respond_to(self, req: &HttpRequest) -> Self::Future
[src]
fn with_status(self, status: StatusCode) -> CustomResponder<Self> where
Self: Sized,
[src]
Self: Sized,
fn with_header<K, V>(self, key: K, value: V) -> CustomResponder<Self> where
Self: Sized,
HeaderName: HttpTryFrom<K>,
V: IntoHeaderValue,
[src]
Self: Sized,
HeaderName: HttpTryFrom<K>,
V: IntoHeaderValue,
impl<T> Responder for InternalError<T> where
T: Debug + Display + 'static,
[src]
T: Debug + Display + 'static,
type Error = Error
type Future = Result<Response, Error>
fn respond_to(self, _: &HttpRequest) -> Self::Future
[src]
fn with_status(self, status: StatusCode) -> CustomResponder<Self> where
Self: Sized,
[src]
Self: Sized,
fn with_header<K, V>(self, key: K, value: V) -> CustomResponder<Self> where
Self: Sized,
HeaderName: HttpTryFrom<K>,
V: IntoHeaderValue,
[src]
Self: Sized,
HeaderName: HttpTryFrom<K>,
V: IntoHeaderValue,
impl<T: Serialize> Responder for Json<T>
[src]
type Error = Error
type Future = Result<Response, Error>
fn respond_to(self, _: &HttpRequest) -> Self::Future
[src]
fn with_status(self, status: StatusCode) -> CustomResponder<Self> where
Self: Sized,
[src]
Self: Sized,
fn with_header<K, V>(self, key: K, value: V) -> CustomResponder<Self> where
Self: Sized,
HeaderName: HttpTryFrom<K>,
V: IntoHeaderValue,
[src]
Self: Sized,
HeaderName: HttpTryFrom<K>,
V: IntoHeaderValue,