From 535c002f79185b282da5fe0929338ee7c53865d0 Mon Sep 17 00:00:00 2001 From: Fabian Reinartz Date: Mon, 8 Jun 2015 21:08:06 +0200 Subject: [PATCH] util/route: add WithParam function. --- util/route/route.go | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/util/route/route.go b/util/route/route.go index 96063ea25b..8d6c2ed718 100644 --- a/util/route/route.go +++ b/util/route/route.go @@ -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) {