square / wire

gRPC and protocol buffers for Android, Kotlin, Swift and Java.
https://square.github.io/wire/
Apache License 2.0
4.24k stars 570 forks source link

GrpcClient.Builder's baseUrl path segments get ignored #2730

Open MariusVolkhart opened 11 months ago

MariusVolkhart commented 11 months ago

When using the compiler to generate a Kotlin client, the GrpcMethod.paths that are generated are absolute. For example /greeter.HelloService/SayHello. The GrpcClient.Builder takes a baseUrl, but since the paths are absolute, and path segments of the baseUrl are discarded when GrpcClient#newCall runs.

If the paths were relative, greeter.HelloService/SayHello (no leading slash), then the baseUrl containing path segments would work fine.

My use case is that I'm adding gRPC to an existing application, and am being asked to deploy it at a path like /appName/grpc/*.

My workaround is an OkHttp interceptor that rewrites the request URL to include the path components I need.

MariusVolkhart commented 11 months ago

I can make a PR with whatever changes, if any, are desired.

oldergod commented 9 months ago

Thanks for reporting. PR welcome !

swankjesse commented 7 months ago

Is this layering with a path prefix something gRPC does elsewhere? I’m unfamiliar with it!