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

The sample in the README makes no sense #54

Open esnible opened 2 years ago

esnible commented 2 years ago
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 )