Skip to content

This issue was moved to a discussion.

You can continue the conversation there. Go to discussion →

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unable to find Tower middleware signature constraints that works with both Axum and Hyper #3508

Closed
francoposa opened this issue Dec 30, 2023 · 0 comments
Labels
C-bug Category: bug. Something is wrong. This is bad!

Comments

@francoposa
Copy link

francoposa commented Dec 30, 2023

Version
hyper 1, http 1

Platform
Linux thinkpad-z13 6.6.6-1-default #1 SMP PREEMPT_DYNAMIC Mon Dec 11 09:46:39 UTC 2023 (a946a9f) x86_64 x86_64 x86_64 GNU/Linux

Description
Attempting to update a tower middleware to work with axum 0.7 and hyper 1.0
Previously works with axum 0.6 and hyper 0.14

I had to unconstrain the Body parameter for Service to be accepted by axum, but now hyper 0.14 and hyper 1.0 won't accept it:
https://github.com/francoposa/tower-otel-http-metrics/pull/4/files

I based the generics signatures off of the tower-http request-id middleware in order to get it working with axum 0.7 again.

Axum 0.7 server code that now works with the updated middleware:
https://github.com/francoposa/tower-otel-http-metrics/blob/axum-0.7-compatibility/examples/axum-http-service/src/main.rs

Hyper 1.0 server code that won't work with the updated middleware or the old middleware:
https://github.com/francoposa/tower-otel-http-metrics/blob/axum-0.7-compatibility/examples/tower-http-service/src/main.rs

I also tried the hyper 1.0 server guide, and get the same issue - in fact the tower http request ID middleware also has the same issue.
I thus far have not found any middleware code examples anywhere that work with both axum 0.7 and hyper 1.0.

error[E0277]: the trait bound `HTTPMetricsService<ServiceFn<fn(hyper::Request<hyper::body::Incoming>) -> impl Future<Output = Result<Response<http_body_util::Full<hyper::body::Bytes>>, Infallible>> {handle}>>: hyper::service::Service<hyper::Request<hyper::body::Incoming>>` is not satisfied
  --> src/main.rs:86:18
   |
86 |                 .serve_connection(io, service)
   |                  ^^^^^^^^^^^^^^^^ the trait `hyper::service::Service<hyper::Request<hyper::body::Incoming>>` is not implemented for `HTTPMetricsService<ServiceFn<fn(hyper::Request<hyper::body::Incoming>) -> impl Future<Output = Result<Response<http_body_util::Full<hyper::body::Bytes>>, Infallible>> {handle}>>`
   |
   = help: the trait `hyper::service::Service<hyper::Request<ReqBody>>` is implemented for `service::util::ServiceFn<F, ReqBody>`
   = note: required for `HTTPMetricsService<ServiceFn<fn(Request<Incoming>) -> impl Future<Output = Result<..., ...>> {handle}>>` to implement `HttpService<hyper::body::Incoming>`
@francoposa francoposa added the C-bug Category: bug. Something is wrong. This is bad! label Dec 30, 2023
@hyperium hyperium locked and limited conversation to collaborators Jan 1, 2024
@seanmonstar seanmonstar converted this issue into discussion #3513 Jan 1, 2024

This issue was moved to a discussion.

You can continue the conversation there. Go to discussion →

Labels
C-bug Category: bug. Something is wrong. This is bad!
Projects
None yet
Development

No branches or pull requests

1 participant