mwitkow / grpc-proxy

gRPC proxy is a Go reverse proxy that allows for rich routing of gRPC calls with minimum overhead.
Apache License 2.0
962 stars 210 forks source link

Allow for Director to set OutgoingMetadata on proxied calls #19

Open mwitkow opened 6 years ago

mwitkow commented 6 years ago

As mentioned in https://github.com/improbable-eng/grpc-web/issues/91 and in discussion of https://github.com/mwitkow/grpc-proxy/pull/16 (@peteredge's comment) we need a way to add metadata to outgoing calls.

The https://github.com/improbable-eng/grpc-web/issues/91 broke because of gRPC-Go changes in 1.5 that separated the inbound and output contexts. This meant that it no longer forwarded the metadata.

I propose the following change:

type StreamDirector func(ctx context.Context, fullMethodName string) (*grpc.ClientConn, error)

to

type StreamDirector func(ctx context.Context, fullMethodName string) (context.Context, *grpc.ClientConn, error)

Where the returned context will be used as a base for the call.

Thoughts? @yifanzz

cleanerx commented 6 years ago

Just ran into this problem. The readme needs adjustment as well, since it reflects to old behavior

yifanzz commented 6 years ago

@mwitkow that looks good to me. Will create a PR for the change.

ghost commented 6 years ago

It seems this was fixed in last commit but issue was not closed.