~samwhited/mux

4facad3d4328b42159f58a337e6109e47828b1b2 — Sam Whited 1 year, 7 months ago 42c12dc
mux: factor out Param into own file
2 files changed, 10 insertions(+), 5 deletions(-)

M mux.go
A params.go
M mux.go => mux.go +0 -5
@@ 205,11 205,6 @@ nodeloop:
// ctxParam is a type used for context keys that contain route parameters.
type ctxParam string

// Param returns the named route parameter from the requests context.
func Param(r *http.Request, name string) interface{} {
	return r.Context().Value(ctxParam(name))
}

// New allocates and returns a new ServeMux.
func New(opts ...Option) *ServeMux {
	mux := &ServeMux{

A params.go => params.go +10 -0
@@ 0,0 1,10 @@
package mux

import (
	"net/http"
)

// Param returns the named route parameter from the requests context.
func Param(r *http.Request, name string) interface{} {
	return r.Context().Value(ctxParam(name))
}