mirror of
https://github.com/prometheus/prometheus.git
synced 2024-11-09 23:24:05 -08:00
util/route: add WithParam function.
This commit is contained in:
parent
ae01a5366d
commit
535c002f79
|
@ -27,6 +27,11 @@ func Param(ctx context.Context, p string) string {
|
|||
return ctx.Value(param(p)).(string)
|
||||
}
|
||||
|
||||
// WithParam returns a new context with param p set to v.
|
||||
func WithParam(ctx context.Context, p, v string) context.Context {
|
||||
return context.WithValue(ctx, param(p), v)
|
||||
}
|
||||
|
||||
// handle turns a Handle into httprouter.Handle
|
||||
func handle(h http.HandlerFunc) httprouter.Handle {
|
||||
return func(w http.ResponseWriter, r *http.Request, params httprouter.Params) {
|
||||
|
|
Loading…
Reference in a new issue