Skip to content

Commit 00ea705

Browse files
authored
Merge pull request #1 from theckman/fix_context
Make sure `Context` sets required fields.
2 parents 5df0663 + 4bf2aac commit 00ea705

File tree

1 file changed

+14
-2
lines changed

1 file changed

+14
-2
lines changed

mux.go

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -128,11 +128,23 @@ func (mux *Mux) ServeHTTP(res http.ResponseWriter, req *http.Request) {
128128
// root is a special case because it is the top node in the tree
129129
if req.URL.Path == slash || req.URL.Path == empty {
130130
if nil != tr.handlers { // root match
131-
(&Context{handler: -1, mux: mux, tree: tr}).Next()
131+
(&Context{
132+
handler: -1,
133+
mux: mux,
134+
tree: tr,
135+
ResponseWriter: res,
136+
Request: req,
137+
}).Next()
132138
return
133139
} else if wild := tr.children[wildcard]; nil != wild {
134140
// root level wildcard pattern match
135-
(&Context{handler: -1, mux: mux, tree: wild}).Next()
141+
(&Context{
142+
handler: -1,
143+
mux: mux,
144+
tree: wild,
145+
ResponseWriter: res,
146+
Request: req,
147+
}).Next()
136148
return
137149
}
138150
http.NotFound(res, req)

0 commit comments

Comments
 (0)