Skip to content

Commit 9f48112

Browse files
kisielkelithrar
authored andcommitted
[docs] Document router.Match (#313)
* Document router.Match The return values are getting confusing. Hopefully this helps. * Simplify some language. * Remove double the
1 parent bc452d9 commit 9f48112

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

mux.go

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,17 @@ type Router struct {
6464
useEncodedPath bool
6565
}
6666

67-
// Match matches registered routes against the request.
67+
// Match attempts to match the given request against the router's registered routes.
68+
//
69+
// If the request matches a route of this router or one of its subrouters the Route,
70+
// Handler, and Vars fields of the the match argument are filled and this function
71+
// returns true.
72+
//
73+
// If the request does not match any of this router's or its subrouters' routes
74+
// then this function returns false. If available, a reason for the match failure
75+
// will be filled in the match argument's MatchErr field. If the match failure type
76+
// (eg: not found) has a registered handler, the handler is assigned to the Handler
77+
// field of the match argument.
6878
func (r *Router) Match(req *http.Request, match *RouteMatch) bool {
6979
for _, route := range r.routes {
7080
if route.Match(req, match) {

0 commit comments

Comments
 (0)