jvdwrf / axum-tonic

36 stars 9 forks source link

Incompatible Grpcweblayer #4

Open timvw01 opened 1 year ago

timvw01 commented 1 year ago

I am trying to enable the grpcweblayer of tonic/tonic-web:

use tonic_web::GrpcWebLayer;

//Service 1
let service_implementation_1 = MyService::new();
let new_service_1 = ServiceServer::new(service_implementation_1);

// The first grpc-service.
let grpc_router_1 = Router::new()
        .nest_tonic(new_service_1)
        .layer(GrpcWebLayer::new());

This results in the following compiler error:

type mismatch resolving `<Route as tower_service::Service<hyper::Request<hyper::Body>>>::Response == hyper::Response<UnsyncBoxBody<bytes::Bytes, Status>>`
expected struct `hyper::Response<UnsyncBoxBody<_, axum::Error>>`
   found struct `hyper::Response<UnsyncBoxBody<_, Status>>`

Perhaps there is an easy way to map the tonic::Status to an axum::Error? Did anyone else run into this? I will try to find a solution.

liamwh commented 1 year ago

Did you find an answer to this @timvw01 ?

rbtcollins commented 9 months ago

https://github.com/hyperium/tonic/discussions/1111 is perhaps relevant

timvw01 commented 8 months ago

I got it to work in the end, but had to make a couple of changes to this crate. I think the changes are too specific for my case to make a pull request, but i can publish the code if desired. Perhaps the suggestion of rbtcollins works as well, haven't checked it yet.

jvdwrf commented 8 months ago

I haven't looked at this code in quite a while, so it takes me some time to dive in to the details of this. If you think it could be valueable to someone else, and improves then I can definetely look at a pull request.

Otherwise we can just leave it as it until someone hits the same problem :)

Ludea commented 1 month ago

I hit issue too (and I would like to use http1 too, like accept_http1(true) )