Skip to content

Commit 60c1c87

Browse files
committed
Merge branch 'hotfix-0.2.2'
2 parents 008b295 + d234c71 commit 60c1c87

1 file changed

Lines changed: 9 additions & 7 deletions

File tree

router.go

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
// license that can be found in the LICENSE file.
44

55
/*
6-
Package router 0.2.1 provides fast HTTP request router.
6+
Package router 0.2.2 provides fast HTTP request router.
77
88
The router matches incoming requests by the request method and the path.
99
If a handle is registered for this path and method, the router delegates the
@@ -185,13 +185,15 @@ func (r *Router) ServeHTTP(w http.ResponseWriter, req *http.Request) {
185185
if r.Logger {
186186
log.Println(req.Method, req.URL.Path)
187187
}
188-
if handle, params, ok := r.handlers[req.Method].get(req.URL.Path); ok {
189-
c := &Control{Request: req, Writer: w}
190-
if len(params) > 0 {
191-
c.Params = append(c.Params, params...)
188+
if _, ok := r.handlers[req.Method]; ok {
189+
if handle, params, ok := r.handlers[req.Method].get(req.URL.Path); ok {
190+
c := &Control{Request: req, Writer: w}
191+
if len(params) > 0 {
192+
c.Params = append(c.Params, params...)
193+
}
194+
handle(c)
195+
return
192196
}
193-
handle(c)
194-
return
195197
}
196198
allowed := make([]string, 0, len(r.handlers))
197199
for method, parser := range r.handlers {

0 commit comments

Comments
 (0)