Enum actix_web::Either [−][src]
Combines two different responder types into a single type
use actix_web::{AsyncResponder, Either, Error, HttpRequest, HttpResponse}; use futures::future::result; type RegisterResult = Either<HttpResponse, Box<Future<Item = HttpResponse, Error = Error>>>; fn index(req: HttpRequest) -> RegisterResult { if is_a_variant() { // <- choose variant A Either::A(HttpResponse::BadRequest().body("Bad data")) } else { Either::B( // <- variant B result(Ok(HttpResponse::Ok() .content_type("text/html") .body("Hello!"))) .responder(), ) } }
Variants
A(A)
First branch of the type
B(B)
Second branch of the type
Trait Implementations
impl<A: Debug, B: Debug> Debug for Either<A, B>
[src]
[+]
impl<A: Debug, B: Debug> Debug for Either<A, B>
impl<A, B> Responder for Either<A, B> where
A: Responder,
B: Responder,
[src]
[+]
impl<A, B> Responder for Either<A, B> where
A: Responder,
B: Responder,
impl<A, B, I, E> Future for Either<A, B> where
A: Future<Item = I, Error = E>,
B: Future<Item = I, Error = E>,
[src]
[+]
impl<A, B, I, E> Future for Either<A, B> where
A: Future<Item = I, Error = E>,
B: Future<Item = I, Error = E>,