grpc / grpc/grpc-rust

Add `Uri` to `tonic::Request`

Open
#1,970 3 comments 4 reactions 0 assignees View on GitHub
Dominant language
Rust
Stars
12.5k
Forks
1.3k
Avg merge
4d 7h
Merged PRs (30d)
24

Description

## 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.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.