grpc-web, Interceptors, and accessing the Client

102 views
Skip to first unread message

Chris Simons

unread,
Oct 16, 2021, 1:37:42 PM10/16/21
to grpc.io
I have a not-that-unique situation where we need to inject additional headers into gRPC unary/stream calls before they go out.

I have a working interceptor but realized that, from within the request object, I only have access to the gRPC path, but not the client's hostname value.

Is there any way to access the client which is sending the request without overriding the interceptor?

Eryu Xia

unread,
Oct 29, 2021, 5:40:39 PM10/29/21
to grpc.io
Thanks for the question, Chris! And sorry for the delay!

To make sure I fully understand, you're asking for a way to access the hostname when intercept() is called, potentially through the client object (although afaiu there's no getter for hostname in the client object either), right?

I wonder, since both the hostname and the interceptor is passed during client construction (example), could you simply also enclose the hostname inside the interceptor object as well? (Or that's what you meant by overriding the interceptor?)

Let me know whether that might work for you.

Thanks! :)

Reply all
Reply to author
Forward
0 new messages