From 016436a22b770ae59060c46cf21120cda1036394 Mon Sep 17 00:00:00 2001 From: crozzy Date: Mon, 2 Jul 2018 16:22:33 -0700 Subject: [PATCH] Updated doc and comments to reflect what the code is doing regarding prefixing gRPC metadata context when dealing with Permanent HTTP header keys --- docs/_docs/usage.md | 5 ++--- runtime/context.go | 3 ++- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/docs/_docs/usage.md b/docs/_docs/usage.md index 8862c523273..2bb0f22cb3b 100644 --- a/docs/_docs/usage.md +++ b/docs/_docs/usage.md @@ -187,8 +187,7 @@ This parameter can be useful to pass request scoped context between the gateway * [How gRPC error codes map to HTTP status codes in the response](https://github.com/grpc-ecosystem/grpc-gateway/blob/master/runtime/errors.go#L15) * HTTP request source IP is added as `X-Forwarded-For` gRPC request header * HTTP request host is added as `X-Forwarded-Host` gRPC request header -* HTTP `Authorization` header is added as `authorization` gRPC request header +* HTTP `Authorization` header is added as `authorization` gRPC request header * Remaining Permanent HTTP header keys (as specified by the IANA [here](http://www.iana.org/assignments/message-headers/message-headers.xhtml) are prefixed with `grpcgateway-` and added with their values to gRPC request header -* HTTP headers that start with 'Grpc-Metadata-' are mapped to gRPC metadata (prefixed with `grpcgateway-`) +* HTTP headers that start with 'Grpc-Metadata-' are mapped to gRPC metadata (after removing prefix 'Grpc-Metadata-') * While configurable, the default {un,}marshaling uses [jsonpb](https://godoc.org/github.com/golang/protobuf/jsonpb) with `OrigName: true`. - diff --git a/runtime/context.go b/runtime/context.go index 90758af099c..03a3015a82a 100644 --- a/runtime/context.go +++ b/runtime/context.go @@ -19,7 +19,8 @@ import ( // parameters to or from a gRPC call. const MetadataHeaderPrefix = "Grpc-Metadata-" -// MetadataPrefix is the prefix for grpc-gateway supplied custom metadata fields. +// MetadataPrefix is prepended to permanent HTTP header keys (as specified +// by the IANA) when added to the gRPC context. const MetadataPrefix = "grpcgateway-" // MetadataTrailerPrefix is prepended to gRPC metadata as it is converted to