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

How to use it ??

sh8 opened this issue · comments

I cannot figure out how to use this library with these codes.

director := func(ctx context.Context) (*grpc.ClientConn, error) {
    if err := CheckBearerToken(ctx); err != nil {
        return nil, grpc.Errorf(codes.PermissionDenied, "unauthorized access: %v", err)
    }
    stream, _ := transport.StreamFromContext(ctx)
    backend, found := PreDialledBackends[stream.Method()];
    if !found {
        return nil, grpc.Errorf(codes.Unimplemented, "the service %v is not implemented", stream.Method)
    }
    return backend, nil
}

proxy := grpcproxy.NewProxy(director)
proxy.Server(boundListener)

I figured out how to use it.
Thanks.