Add a CallOption for modifying the :authority header #5787
Closed
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR just adds a
CallOption
that makes us able to modify the:authority
header per RPC.Related: #5361
My use case for modifying
:authority
header per RPCI'm using Google Cloud Run, a managed container platform, for running my applications.
Google Cloud Run creates a dedicated domain for each deployment like
my-service-xxx.run.app
.In addition to this dedicated domain, Google Cloud Run also accepts a HTTP (gRPC) request on the single domain
run.app
and routes a request based on the:authority
header like below:This dynamic routing capability is very useful if
grpc-go
has aCallOption
for modifying the:authority
header per RPC instead of the per connection basis.For example, let's assume we have two gRPC Servers, Server A and B, and develop two features for Server B simultaneously. When we deploy each feature as a dedicated server (B-1 and B-2) and if Server A can modify the
:authority
header for Server B based on its incoming header (metadata), developers can choose which Servers (B-1 or B-2) does Server A send the request dynamically like below:To achieve this dynamic routing, we can use the
Authority
CallOption introduced by this PR like below:I know there are concerns about modifying the
:authority
regarding TLS as described in this issue, but I think adding a CallOption for modifyingauthority
might be able to be implemented independently.P.S.
I know this PR does not include any test for the new CallOption. If this PR is acceptable I'd like to finalize this PR by writing tests, so I would appreciate it if anyone could let me know the right place to write the test for this type of change.