diff options
Diffstat (limited to 'vendor/github.com/prometheus/common/route')
-rw-r--r-- | vendor/github.com/prometheus/common/route/route.go | 7 | ||||
-rw-r--r-- | vendor/github.com/prometheus/common/route/route_test.go | 2 |
2 files changed, 5 insertions, 4 deletions
diff --git a/vendor/github.com/prometheus/common/route/route.go b/vendor/github.com/prometheus/common/route/route.go index 930b52d4f..1e5638ed9 100644 --- a/vendor/github.com/prometheus/common/route/route.go +++ b/vendor/github.com/prometheus/common/route/route.go @@ -33,18 +33,19 @@ func WithParam(ctx context.Context, p, v string) context.Context { return context.WithValue(ctx, param(p), v) } -type contextFn func(r *http.Request) (context.Context, error) +// ContextFunc returns a new context for a request. +type ContextFunc func(r *http.Request) (context.Context, error) // Router wraps httprouter.Router and adds support for prefixed sub-routers // and per-request context injections. type Router struct { rtr *httprouter.Router prefix string - ctxFn contextFn + ctxFn ContextFunc } // New returns a new Router. -func New(ctxFn contextFn) *Router { +func New(ctxFn ContextFunc) *Router { if ctxFn == nil { ctxFn = func(r *http.Request) (context.Context, error) { return context.Background(), nil diff --git a/vendor/github.com/prometheus/common/route/route_test.go b/vendor/github.com/prometheus/common/route/route_test.go index 4055d69d5..e7b1cba33 100644 --- a/vendor/github.com/prometheus/common/route/route_test.go +++ b/vendor/github.com/prometheus/common/route/route_test.go @@ -29,7 +29,7 @@ func TestRedirect(t *testing.T) { } } -func TestContextFn(t *testing.T) { +func TestContextFunc(t *testing.T) { router := New(func(r *http.Request) (context.Context, error) { return context.WithValue(context.Background(), "testkey", "testvalue"), nil }) |