Closed subhojit777 closed 5 years ago
Blocked because of the error
error[E0308]: match arms have incompatible types --> src/answers.rs:34:34 34 .and_then( code match code { __^ 35 StatusCode::OK => { 36 let answer = answer_form.into_inner(); 37 ... 47 StatusCode::FORBIDDEN => Ok(HttpResponse::Forbidden().into()), ------------------------------------ match arm with an incompatible type 48 _ => Ok(HttpResponse::NotAcceptable().into()), 49 }) _____^ expected struct futures::AndThen
, found enumstd::result::Result
= note: expected type
futures::AndThen<futures::future::FromErr<actix_web::actix::Request<DbExecutor, models::AnswerForm>, _>, std::result::Result<actix_web::HttpResponse, _>, [closure@src/answers.rs:42:39: 45:30]>
found typestd::result::Result<_, _>
I think this should fix it https://stackoverflow.com/questions/53119182/conditionally-chaining-a-rust-future-based-on-initial-future-result
The above approach will not work, because conditionally it returns AndThen
or Result
, however, it should return only Return
. And I don't think it is possible to do that here. Therefore, I have decided to move the guard check to middleware. I am following https://users.rust-lang.org/t/trouble-with-lifetimes-in-actix-web-middleware/21836 for code.
Next steps:
GET /answers-get