mwitkow / grpc-proxy

gRPC proxy is a Go reverse proxy that allows for rich routing of gRPC calls with minimum overhead.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

The sample in the README makes no sense

esnible opened this issue · comments

director = func(ctx context.Context, fullMethodName string) (context.Context, *grpc.ClientConn, error) {
    md, _ := metadata.FromIncomingContext(ctx)
    outCtx = metadata.NewOutgoingContext(ctx, md.Copy())
    // cc is probably intended to be the ClientConn?
    return outCtx, cc, nil
	
    // >>>> THIS CODE IS DEAD
    // Make sure we never forward internal services.
    if strings.HasPrefix(fullMethodName, "/com.example.internal.") {
        return outCtx, nil, status.Errorf(codes.Unimplemented, "Unknown method")
    }

Note that I stumbled onto this because some code I was writing that uses mwitkow/grpc-proxy stopped working after this change. (I spent several hours on it and still don't understand what went wrong. The code that is failing is https://github.com/observatorium/api/pull/199/files#diff-2873f79a86c0d8b3335cd7731b0ecf7dd4301eb19a82ef7a1cba7589b5252261R1049 )