From a5f73e0d60f593afb10c464def9d0500d484687a Mon Sep 17 00:00:00 2001 From: "Alexander \"Arav\" Andreev" Date: Mon, 7 Feb 2022 22:50:46 +0400 Subject: [PATCH] A new SetNotFoundHandler() method for server. --- pkg/server/http.go | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/pkg/server/http.go b/pkg/server/http.go index 61846d9..1a88740 100644 --- a/pkg/server/http.go +++ b/pkg/server/http.go @@ -53,6 +53,10 @@ func (s *HttpServer) ServeStatic(path string, fsys http.FileSystem) { s.router.ServeFiles(path, fsys) } +func (s *HttpServer) SetNotFoundHandler(handler http.HandlerFunc) { + s.router.NotFound = handler +} + // GetURLParam wrapper around underlying router for getting URL parameters. func GetURLParam(r *http.Request, param string) string { return httprouter.ParamsFromContext(r.Context()).ByName(param)