Skip to content

Commit e87d364

Browse files
committed
remove panic when method not found in tree
1 parent 0459c44 commit e87d364

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

router.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -254,7 +254,8 @@ func (r *Router) ServeHTTP(w http.ResponseWriter, req *http.Request) {
254254
}
255255

256256
if _, ok := r.trees[req.Method]; !ok {
257-
panic(fmt.Errorf("Error method or method is not registered "))
257+
r.HandleNotFound(w, req, r.middleware)
258+
return
258259
}
259260

260261
nodes := r.trees[req.Method].Find(requestUrl, false)

0 commit comments

Comments
 (0)