PathParams not a method on router
This commit is contained in:
16
router.go
16
router.go
@ -112,14 +112,6 @@ func (r *Router) AddRoute(method string, path string, callback http.HandlerFunc)
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
// PathParams takes a path and returns the values for any path parameters
|
|
||||||
// in the path.
|
|
||||||
func (r *Router) PathParams(req *http.Request) (params map[string]string) {
|
|
||||||
params = req.Context().Value(paramKey).(map[string]string)
|
|
||||||
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
// handler returns the handler to use for the given request, consulting r.Method, r.URL.Path. It
|
// handler returns the handler to use for the given request, consulting r.Method, r.URL.Path. It
|
||||||
// always returns a non-nil handler.
|
// always returns a non-nil handler.
|
||||||
//
|
//
|
||||||
@ -161,6 +153,14 @@ func (r *Router) ServeHTTP(w http.ResponseWriter, req *http.Request) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// PathParams takes a path and returns the values for any path parameters
|
||||||
|
// in the path.
|
||||||
|
func PathParams(req *http.Request) (params map[string]string) {
|
||||||
|
params = req.Context().Value(paramKey).(map[string]string)
|
||||||
|
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
// addSegment create a new segment either as a child or as a parameter depending on whether the key
|
// addSegment create a new segment either as a child or as a parameter depending on whether the key
|
||||||
// qualifies as a parameter. A pointer to the created segment is then returned.
|
// qualifies as a parameter. A pointer to the created segment is then returned.
|
||||||
func addSegment(curr *segment, key string) (seg *segment) {
|
func addSegment(curr *segment, key string) (seg *segment) {
|
||||||
|
Reference in New Issue
Block a user