Skip to content
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

Add Uri to tonic::Request #1970

Open
shikhar opened this issue Oct 3, 2024 · 1 comment
Open

Add Uri to tonic::Request #1970

shikhar opened this issue Oct 3, 2024 · 1 comment

Comments

@shikhar
Copy link
Contributor

shikhar commented Oct 3, 2024

Feature Request

Crates

tonic

Motivation

A gRPC service may be accessible at multiple endpoints and knowing the hostname can be meaningful.

With HTTP1.1 this is usually available as the Host header and could have been accessed from the MetadataMap, but given the HTTP/2 context the right way to access this is the authority pseudoheader from the URI.

https://docs.rs/http/latest/http/request/struct.Request.html#method.uri
https://docs.rs/http/latest/http/uri/struct.Uri.html#method.authority

However, this is not currently available to tonic services.

Proposal

Add a uri: Uri field to tonic::Request and a getter for it. This field should be copied over from the http::Request.

Alternatives

A layer that adds the URI or required components (e.g. request.uri().authority()) as an extension.

@shikhar
Copy link
Contributor Author

shikhar commented Oct 6, 2024

Had a go at plumbing this up, and it's not pretty. Another solution could be to add the Uri as an extension (by default, can be done by a custom layer already of course)...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant