diff --git a/main.go b/main.go index c0fc117d3..e71ccf825 100644 --- a/main.go +++ b/main.go @@ -5,7 +5,6 @@ import ( "crypto/tls" "encoding/json" "fmt" - "google.golang.org/grpc" "io" "log" "net" @@ -36,6 +35,7 @@ import ( grpc_proxy "github.com/mwitkow/grpc-proxy/proxy" "github.com/pkg/profile" dmp "github.com/sergi/go-diff/diffmatchpatch" + "google.golang.org/grpc" ) // version contains the version number @@ -158,7 +158,6 @@ func newGrpcProxy(cfg *config.Config, tlscfg *tls.Config) []grpc.ServerOption { return []grpc.ServerOption{ grpc.CustomCodec(grpc_proxy.Codec()), grpc.UnknownServiceHandler(handler), - grpc.UnaryInterceptor(proxyInterceptor.Unary), grpc.StreamInterceptor(proxyInterceptor.Stream), grpc.StatsHandler(statsHandler), } diff --git a/proxy/grpc_handler.go b/proxy/grpc_handler.go index 381a47c42..6b16b7c3a 100644 --- a/proxy/grpc_handler.go +++ b/proxy/grpc_handler.go @@ -99,27 +99,6 @@ func (p proxyStream) Context() context.Context { return p.ctx } -func (g GrpcProxyInterceptor) Unary(ctx context.Context, req interface{}, info *grpc.UnaryServerInfo, handler grpc.UnaryHandler) (interface{}, error) { - target, err := g.lookup(ctx, info.FullMethod) - - if err != nil { - return nil, err - } - - ctx = context.WithValue(ctx, targetKey{}, target) - - start := time.Now() - - res, err := handler(ctx, req) - - end := time.Now() - dur := end.Sub(start) - - target.Timer.Update(dur) - - return res, err -} - func (g GrpcProxyInterceptor) Stream(srv interface{}, stream grpc.ServerStream, info *grpc.StreamServerInfo, handler grpc.StreamHandler) error { ctx := stream.Context()