devashishdxt / tonic-web-wasm-client

Other
104 stars 28 forks source link

InterceptedService support for the client #29

Closed lukasztab closed 1 year ago

lukasztab commented 1 year ago

Hello. Is there any chance to add InterceptedService support for the client? I get the following errors while I try to use it:

error[E0277]: the trait bound `ResponseBody: Default` is not satisfied
let client = AppServiceClient::with_interceptor(
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `Default` is not implemented for `ResponseBody`
note: required by a bound in `common::app::app_service_client::AppServiceClient::<T>::with_interceptor` T::ResponseBody: Default,
required by this bound in `common::app::app_service_client::AppServiceClient::<T>::with_interceptor`

error[E0599]: the method `set_app_property` exists for struct `AppServiceClient<InterceptedService<tonic_web_wasm_client::Client, AddJwtInterceptor>>`, but its trait bounds were not satisfied

client.set_app_property(req).await?;
       ^^^^^^^^^^^^^^^^^ method cannot be called on `AppServiceClient<InterceptedService<tonic_web_wasm_client::Client, AddJwtInterceptor>>` due to unsatisfied trait bounds
pub struct InterceptedService<S, F> {
doesn't satisfy `<_ as Service<request::Request<http_body::combinators::box_body::UnsyncBoxBody<tonic::codegen::Bytes, tonic::Status>>>>::Response = response::Response<_>`
doesn't satisfy `_: GrpcService<http_body::combinators::box_body::UnsyncBoxBody<tonic::codegen::Bytes, tonic::Status>>`
doesn't satisfy `_: Service<request::Request<http_body::combinators::box_body::UnsyncBoxBody<tonic::codegen::Bytes, tonic::Status>>>`
note: the following trait bounds were not satisfied:
`InterceptedService<tonic_web_wasm_client::Client, AddJwtInterceptor>: GrpcService<http_body::combinators::box_body::UnsyncBoxBody<tonic::codegen::Bytes, tonic::Status>>`
`<InterceptedService<tonic_web_wasm_client::Client, AddJwtInterceptor> as Service<request::Request<http_body::combinators::box_body::UnsyncBoxBody<tonic::codegen::Bytes, tonic::Status>>>>::Response = response::Response<_>`
`InterceptedService<tonic_web_wasm_client::Client, AddJwtInterceptor>: Service<request::Request<http_body::combinators::box_body::UnsyncBoxBody<tonic::codegen::Bytes, tonic::Status>>>`

Is the missing Default trait for ResponseBody a problem?

devashishdxt commented 1 year ago

Hi. Thanks for creating the issue.

I've created a branch with Default implementation for ResponseBody. Can you test it before merging?

https://github.com/devashishdxt/tonic-web-wasm-client/tree/response-body-default

lukasztab commented 1 year ago

Hey. Thanks for an instant solution. I'll try it tomorrow.

lukasztab commented 1 year ago

I just tested it. All works fine.