From 6f72a024fa0cb49022bd91c0a6a08d7b9f78767d Mon Sep 17 00:00:00 2001 From: pg9182 <96569817+pg9182@users.noreply.github.com> Date: Thu, 13 Oct 2022 02:49:13 -0400 Subject: pkg/api/api0: Add NotFound handler --- pkg/api/api0/api.go | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) (limited to 'pkg/api/api0/api.go') diff --git a/pkg/api/api0/api.go b/pkg/api/api0/api.go index 40aa90b..fe869af 100644 --- a/pkg/api/api0/api.go +++ b/pkg/api/api0/api.go @@ -20,6 +20,7 @@ import ( type Handler struct { PdataStorage PdataStorage + NotFound http.Handler } func (h *Handler) ServeHTTP(w http.ResponseWriter, r *http.Request) { @@ -29,10 +30,12 @@ func (h *Handler) ServeHTTP(w http.ResponseWriter, r *http.Request) { case strings.HasPrefix(r.URL.Path, "/player/"): // TODO: rate limit h.handlePlayer(w, r) - return default: - http.Error(w, http.StatusText(http.StatusNotFound), http.StatusNotFound) - return + if h.NotFound == nil { + http.Error(w, http.StatusText(http.StatusNotFound), http.StatusNotFound) + } else { + h.NotFound.ServeHTTP(w, r) + } } } -- cgit v1.2.3