Hi, I'm implementing a proxy handlers chain with both hudsucker
and axum
. Getting three similar lifetime errors:
error: higher-ranked lifetime error
--> src/proxy/chain.rs:89:9
|
89 | / async move {
90 | | match chain.process_request(request).await {
91 | | Ok(HttpResult::Request(request)) => RequestOrResponse::Request(request),
92 | | Ok(HttpResult::Response(response)) => RequestOrResponse::Response(response),
93 | | Err(_) => RequestOrResponse::Response(Response::new(ForwardBody::empty())),
94 | | }
95 | | }
| |_________^
error: higher-ranked lifetime error
--> src/proxy/chain.rs:104:9
|
104 | / async move {
105 | | chain.process_response(response).await.unwrap_or_else(|_| Response::new(ForwardBody::empty()))
106 | | }
| |_________^
error: higher-ranked lifetime error
--> src/proxy/chain.rs:116:9
|
116 | / Box::pin(async move {
117 | | let response = match chain.process_request(request).await {
118 | | Ok(HttpResult::Request(request)) => match client.request(request).await {
119 | | Ok(response) => response.into_response(),
... |
126 | | chain.process_response(response).await.unwrap_or_else(|_| Response::new(ReverseBody::empty()))
127 | | })
| |__________^
|
= note: could not prove `Pin<Box<{async block@src/proxy/chain.rs:116:18: 116:28}>>: CoerceUnsized<Pin<Box<(dyn futures::Future<Output = http::Response<axum::body::Body>> + std::marker::Send + 'b)>>>`
The errors occur in both hudsucker::HttpHandler
and axum::handler::Handler
implementations for my Chain
type.
Here is my project: GitHub - airycanon/higher-ranked-lifetime-demo
How can I properly implement both handler traits? Thanks for any help!