I am trying to send a message to one db handler, and based on the result send a message to a second handler, or return an error from the first.
What I've come up with so far doesn't work; rustc says match arms have incompatible types
expected struct 'futures::future::and_then::AndThen', found enum 'std::result::Result'
state
.db
.send(...)
.from_err()
.and_then(|res| match res {
Ok(response) => {
// Do some additional logic here
state
.db
.send(...)
.from_err()
.and_then(|res| match res {
Ok(response) => Ok(HttpResponse::Ok().json(response)),
Err(err) => Ok(HttpResponse::InternalServerError().body(err.to_string()))
})
},
Err(err) => Ok(HttpResponse::InternalServerError().body(err.to_string()))
})
.responder()
Question how to accomplish this in actix-web?