// +build go1.7packagehttprouterimport("context""net/http")typeparamsKeystruct{}// ParamsKey is the request context key under which URL params are stored.//// This is only present from go 1.7.varParamsKey=paramsKey{}// Handler is an adapter which allows the usage of an http.Handler as a// request handle. With go 1.7+, the Params will be available in the// request context under ParamsKey.func(r*Router)Handler(method,pathstring,handlerhttp.Handler){r.Handle(method,path,func(whttp.ResponseWriter,req*http.Request,pParams){ctx:=req.Context()ctx=context.WithValue(ctx,ParamsKey,p)req=req.WithContext(ctx)handler.ServeHTTP(w,req)},)}// ParamsFromContext pulls the URL parameters from a request context,// or returns nil if none are present.//// This is only present from go 1.7.funcParamsFromContext(ctxcontext.Context)Params{p,_:=ctx.Value(ParamsKey).(Params)returnp}