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

how to get customezing header #1244

Closed
jackwener opened this issue Apr 27, 2020 · 3 comments
Closed

how to get customezing header #1244

jackwener opened this issue Apr 27, 2020 · 3 comments

Comments

@jackwener
Copy link

phenomenon

send HTTP request with customezing header
(add by postman)
"id": "123456"

I achieve this function by the following code:

md, ok := metadata.FromIncomingContext(ctx)
fmt.Prlnln(md)

but output don't include customezing header kv

@johanbrandhorst
Copy link
Collaborator

Hi @jackwener, thanks for your issue. If you want to map a custom header, you can either prefix it with Grpc-metadata- and have it translated automatically:

"Grpc-metadata-id": "123456"
md, ok := metadata.FromIncomingContext(ctx)
// md["grpcgateway-id"] == "123456"

Or add an IncomingHeaderMatcher. We have a section on how to do that in the documentation: https://grpc-ecosystem.github.io/grpc-gateway/docs/customizingyourgateway.html.

@jackwener
Copy link
Author

Hi @jackwener, thanks for your issue. If you want to map a custom header, you can either prefix it with Grpc-metadata- and have it translated automatically:

"Grpc-metadata-id": "123456"
md, ok := metadata.FromIncomingContext(ctx)
// md["grpcgateway-id"] == "123456"

Or add an IncomingHeaderMatcher. We have a section on how to do that in the documentation: https://grpc-ecosystem.github.io/grpc-gateway/docs/customizingyourgateway.html.

thanks, I'm sorry I didn't read the document carefully。
But it seem that translated automatically not in document.

@johanbrandhorst
Copy link
Collaborator

The first part is in the README: https://github.com/grpc-ecosystem/grpc-gateway#features

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

2 participants