-
Notifications
You must be signed in to change notification settings - Fork 1k
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
feat(transport): add user-agent header to client requests. #457
Conversation
* Adds a default user-agent to tonic `Channel`. * The user agent can be configured through the `Channel` builder. fixes hyperium#453
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, just one style nit, should we consider adding tests for this?
Sure, I'll add a test. |
ha, weird merging of imports, hang on... |
This is awesome, @alce - thanks for working on it! |
@alertedsnake thanks! And thank you for reporting the issue. |
Just confirmed this is working perfectly in my real-world situation, so thanks again :) |
This PR adds a user-agent header to client requests. The default value is
tonic/x.x.x
. The value can be configured through theChannel
builder.The value passed to the
user_agent
method will be prepended to the default, in this case the full value will be:Greeter 1.1 tonic/0.3.1
.The header is added by a new
UserAgent
layer in the client's service stack. While this is not the most straight forward implementation, it seemed to be the cleanest and safest one. It also aligns better with other client implementations (grpc-go clients, in particular).Alternatives
user-agent
from the list of grpc reserved headers.user-agent
header in tonic <-> http request conversions.Endpoint
to theclient::Grpc
struct and set the header after converting the request....and maybe others.
fixes #453