From 9861155d5f23d6aaf4a0c408c5c74740064a026a Mon Sep 17 00:00:00 2001 From: Peter Kieltyka Date: Tue, 8 Jan 2019 12:53:40 -0500 Subject: [PATCH] fixes #362, return 404 when routing to empty mux --- mux.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/mux.go b/mux.go index 84a2424a..e553287e 100644 --- a/mux.go +++ b/mux.go @@ -60,7 +60,8 @@ func NewMux() *Mux { func (mx *Mux) ServeHTTP(w http.ResponseWriter, r *http.Request) { // Ensure the mux has some routes defined on the mux if mx.handler == nil { - panic("chi: attempting to route to a mux with no handlers.") + mx.NotFoundHandler().ServeHTTP(w, r) + return } // Check if a routing context already exists from a parent router.