// NewMiddleware returns middleware to set logger to context
NewMiddleware returns middleware to set logger to context
// NewMiddleware returns middleware to set logger to context
func NewMiddleware(gcpProjectID string, logger *zap.Logger) func(next http.Handler) http.Handler {
	return func(next http.Handler) http.Handler {
		return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
			t := newTraceFromTraceContext(gcpProjectID, r.Header.Get("X-Cloud-Trace-Context"))
			zapFields := append(
				zapdriver.TraceContext(t.TraceID, t.SpanID, true, t.ProjectID),
				zap.String("ip", r.RemoteAddr),
				zap.String("requestId", middleware.GetReqID(r.Context())),
			)
			ctx := ctxzap.ToContext(r.Context(), logger.With(zapFields...))
			next.ServeHTTP(w, r.WithContext(ctx))
		})
	}
}
func NewMiddleware ( gcpProjectID string , logger * zap . Logger ) func ( next http . Handler ) http . Handler { return func ( next http . Handler ) http . Handler { return http . HandlerFunc ( func ( w http . ResponseWriter , r * http . Request ) { t := newTraceFromTraceContext ( gcpProjectID , r . Header . Get ( " " ) ) zapFields := append ( zapdriver . TraceContext ( t . TraceID , t . SpanID , true , t . ProjectID ) , zap . String ( " " , r . RemoteAddr ) , zap . String ( " " , middleware . GetReqID ( r . Context ( ) ) ) , ) ctx := ctxzap . ToContext ( r . Context ( ) , logger . With ( zapFields ... ) ) next . ServeHTTP ( w , r . WithContext ( ctx ) ) } ) } }
NewMiddleware returns middleware to set logger to context
NewMiddleware returns middleware to set logger to context