From 355e5c77c9b93d7fa530781322c8bf11e44d9799 Mon Sep 17 00:00:00 2001 From: jacobmikesell Date: Tue, 28 Oct 2025 14:19:39 -0700 Subject: [PATCH] expose the type --- contrib/net/http/internal/wrap/handler.go | 49 ++++++++++++----------- 1 file changed, 26 insertions(+), 23 deletions(-) diff --git a/contrib/net/http/internal/wrap/handler.go b/contrib/net/http/internal/wrap/handler.go index 1a4e994213..532a886c51 100644 --- a/contrib/net/http/internal/wrap/handler.go +++ b/contrib/net/http/internal/wrap/handler.go @@ -33,27 +33,30 @@ func Handler(h http.Handler, service, resource string, opts ...internal.Option) if service == "" { service = cfg.ServiceName } - return http.HandlerFunc(func(w http.ResponseWriter, req *http.Request) { - if cfg.IgnoreRequest(req) { - h.ServeHTTP(w, req) - return - } - resc := resource - if r := cfg.ResourceNamer(req); r != "" { - resc = r - } - so := make([]tracer.StartSpanOption, len(cfg.SpanOpts), len(cfg.SpanOpts)+1) - copy(so, cfg.SpanOpts) - so = append(so, httptrace.HeaderTagsFromRequest(req, cfg.HeaderTags)) - TraceAndServe(h, w, req, &httptrace.ServeConfig{ - Framework: "net/http", - Service: service, - Resource: resc, - FinishOpts: cfg.FinishOpts, - SpanOpts: so, - IsStatusError: cfg.IsStatusError, - Route: pattern.Route(req.Pattern), - RouteParams: pattern.PathParameters(req.Pattern, req), - }) - }) + + return WrappedHandler{ + HandlerFunc: http.HandlerFunc(func(w http.ResponseWriter, req *http.Request) { + if cfg.IgnoreRequest(req) { + h.ServeHTTP(w, req) + return + } + resc := resource + if r := cfg.ResourceNamer(req); r != "" { + resc = r + } + so := make([]tracer.StartSpanOption, len(cfg.SpanOpts), len(cfg.SpanOpts)+1) + copy(so, cfg.SpanOpts) + so = append(so, httptrace.HeaderTagsFromRequest(req, cfg.HeaderTags)) + TraceAndServe(h, w, req, &httptrace.ServeConfig{ + Framework: "net/http", + Service: service, + Resource: resc, + FinishOpts: cfg.FinishOpts, + SpanOpts: so, + IsStatusError: cfg.IsStatusError, + Route: pattern.Route(req.Pattern), + RouteParams: pattern.PathParameters(req.Pattern, req), + }) + }), + } }