server-go/internal/router/params_legacy.go

17 lines
424 B
Go
Raw Normal View History

2018-08-22 08:37:12 +00:00
// +build !go1.7
package router
import "net/http"
// 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, path string, handler http.Handler) {
r.Handle(method, path,
func(w http.ResponseWriter, req *http.Request, _ Params) {
handler.ServeHTTP(w, req)
},
)
}