我正在尝试使用 Actix-Web 实现 HTTP 请求处理程序。这是我的代码的相关部分:
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()
}
}
但是,我收到此错误消息:
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
我根本不明白这个错误信息。该代码实际上与此示例相同,它不包含任何生命周期注释。