From e489a101f631db31ec7c6d97ca4d8034c573031a Mon Sep 17 00:00:00 2001 From: Nolan Woods Date: Sun, 2 May 2021 01:01:34 -0700 Subject: [PATCH] lib/http: add default 404 handler --- lib/http/http.go | 3 +++ 1 file changed, 3 insertions(+) diff --git a/lib/http/http.go b/lib/http/http.go index 25e5ff82d..61525bab4 100644 --- a/lib/http/http.go +++ b/lib/http/http.go @@ -173,6 +173,9 @@ func NewServer(listeners, tlsListeners []net.Listener, opt Options) (Server, err router.MethodNotAllowed(func(w http.ResponseWriter, _ *http.Request) { http.Error(w, http.StatusText(http.StatusMethodNotAllowed), http.StatusMethodNotAllowed) }) + router.NotFound(func(w http.ResponseWriter, _ *http.Request) { + http.Error(w, http.StatusText(http.StatusNotFound), http.StatusNotFound) + }) handler := router.(http.Handler) if opt.BaseURL != "" {