-
Notifications
You must be signed in to change notification settings - Fork 2.2k
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
How to retrieve data from a gRPC handler in HTTP middleware #3775
Comments
I'm trying to achieve something similar, I think it would be beneficial to have something like a functional interface for wrapping I'm trying to add support in go-http-metrics for the runtime mux, and although I can do this easily for custom methods, there are no viable alternatives of conciliating these two libraries. In my case if I went for a solution close to what @LazarenkoA has done here, it would be senseless to use go-http-metrics. |
What you're suggesting is the only way I know of to pass extra information from gRPC handlers into HTTP middleware. I don't think this is too rare of a use case (e.g., setting cookies from gRPC handlers) so I'd be interested in exploring the solution space, if you're interested in working on it. |
I'm facing a challenge where I need to extract specific data from a gRPC handler into my HTTP middleware. Despite thoroughly reviewing the documentation, I couldn't find a suitable answer. In my current implementation, I've utilized WithForwardResponseOption in runtime.NewServeMux to inject values into the HTTP response headers and subsequently retrieve them in the middleware. However, I find this solution somewhat inelegant, are there any other ways?
here's how I tried to solve this problem:
on the grpc handler side
The text was updated successfully, but these errors were encountered: