util/route: add WithParam function.

This commit is contained in:
Fabian Reinartz 2015-06-08 21:08:06 +02:00
parent ae01a5366d
commit 535c002f79

View file

@ -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) {