diff --git a/transport/grpc/interceptor.go b/transport/grpc/interceptor.go index 3f3827f69..26daedfb8 100644 --- a/transport/grpc/interceptor.go +++ b/transport/grpc/interceptor.go @@ -17,12 +17,15 @@ func (s *Server) unaryServerInterceptor() grpc.UnaryServerInterceptor { defer cancel() md, _ := grpcmd.FromIncomingContext(ctx) replyHeader := grpcmd.MD{} - ctx = transport.NewServerContext(ctx, &Transport{ - endpoint: s.endpoint.String(), + tr := &Transport{ operation: info.FullMethod, reqHeader: headerCarrier(md), replyHeader: headerCarrier(replyHeader), - }) + } + if s.endpoint != nil { + tr.endpoint = s.endpoint.String() + } + ctx = transport.NewServerContext(ctx, tr) if s.timeout > 0 { ctx, cancel = context.WithTimeout(ctx, s.timeout) defer cancel() diff --git a/transport/http/server.go b/transport/http/server.go index 637ef72ab..64c42df11 100644 --- a/transport/http/server.go +++ b/transport/http/server.go @@ -153,7 +153,6 @@ func NewServer(opts ...ServerOption) *Server { Handler: FilterChain(srv.filters...)(srv.router), TLSConfig: srv.tlsConf, } - srv.err = srv.listenAndEndpoint() return srv } @@ -208,14 +207,15 @@ func (s *Server) filter() mux.MiddlewareFunc { } tr := &Transport{ - endpoint: s.endpoint.String(), operation: pathTemplate, reqHeader: headerCarrier(req.Header), replyHeader: headerCarrier(w.Header()), request: req, pathTemplate: pathTemplate, } - + if s.endpoint != nil { + tr.endpoint = s.endpoint.String() + } tr.request = req.WithContext(transport.NewServerContext(ctx, tr)) next.ServeHTTP(w, tr.request) })