lib/http: add default 404 handler

This commit is contained in:
Nolan Woods 2021-05-02 01:01:34 -07:00 committed by Nick Craig-Wood
parent 35a86193b7
commit e489a101f6
1 changed files with 3 additions and 0 deletions

View File

@ -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 != "" {