1
0

A new SetNotFoundHandler() method for server.

This commit is contained in:
Alexander Andreev 2022-02-07 22:50:46 +04:00
parent 8a4104c3d5
commit a5f73e0d60
Signed by: Arav
GPG Key ID: 1327FE8A374CC86F

View File

@ -53,6 +53,10 @@ func (s *HttpServer) ServeStatic(path string, fsys http.FileSystem) {
s.router.ServeFiles(path, fsys) 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. // GetURLParam wrapper around underlying router for getting URL parameters.
func GetURLParam(r *http.Request, param string) string { func GetURLParam(r *http.Request, param string) string {
return httprouter.ParamsFromContext(r.Context()).ByName(param) return httprouter.ParamsFromContext(r.Context()).ByName(param)