I am trying to implement an HTTP request handler using Actix-Web. Here is the relevant part of my code:
impl<S> Handler<S> for FooBarHandler {
type Result = Box<Future<Item = HttpResponse, Error = Error>>;
fn handle(&mut self, req : HttpRequest<S>) -> Self::Result {
req.json().from_err().and_then(|foo : Foo|
self.baz.qux(foo);
Ok(HttpResponse::Ok().finish())
}).responder()
}
}
However, I receive this error message:
error[E0477]: the type `mymod::futures::AndThen<mymod::futures::future::FromErr<mymod::actix_web::dev::JsonBody<mymod::actix_web::HttpRequest<S>, mymod::Foo>, mymod::actix_web::Error>, std::result::Result<mymod::actix_web::HttpResponse, mymod::actix_web::Error>, [closure@src/mymod.rs:53:40: 56:10 self:&&mut mymod::FooBarHandler]>` does not fulfill the required lifetime
--> src/mymod.rs:56:12
|
56 | }).responder()
| ^^^^^^^^^
|
= note: type must satisfy the static lifetime
I do not understand this error message at all. The code is practically identical to this example, which does not contain any lifetime annotations.
FooBarHandler, you haven't shown what crates (and their versions!) you are importing, etc. In fact, your code isn't syntactically valid. - Shepmaster