Skip to content

Commit

Permalink
Merge pull request #1 from theckman/fix_context
Browse files Browse the repository at this point in the history
Make sure `Context` sets required fields.
  • Loading branch information
afshin authored Sep 25, 2016
2 parents 5df0663 + 4bf2aac commit 00ea705
Showing 1 changed file with 14 additions and 2 deletions.
16 changes: 14 additions & 2 deletions mux.go
Original file line number Diff line number Diff line change
Expand Up @@ -128,11 +128,23 @@ func (mux *Mux) ServeHTTP(res http.ResponseWriter, req *http.Request) {
// root is a special case because it is the top node in the tree
if req.URL.Path == slash || req.URL.Path == empty {
if nil != tr.handlers { // root match
(&Context{handler: -1, mux: mux, tree: tr}).Next()
(&Context{
handler: -1,
mux: mux,
tree: tr,
ResponseWriter: res,
Request: req,
}).Next()
return
} else if wild := tr.children[wildcard]; nil != wild {
// root level wildcard pattern match
(&Context{handler: -1, mux: mux, tree: wild}).Next()
(&Context{
handler: -1,
mux: mux,
tree: wild,
ResponseWriter: res,
Request: req,
}).Next()
return
}
http.NotFound(res, req)
Expand Down

0 comments on commit 00ea705

Please sign in to comment.