1
0
mirror of https://github.com/muety/wakapi.git synced 2023-08-10 21:12:56 +03:00

chore: log unmatched requests

This commit is contained in:
Ferdinand Mütsch 2021-06-24 21:40:51 +02:00
parent 312dfb36d8
commit c3957ec0c8

10
main.go
View File

@ -189,6 +189,14 @@ func main() {
rootRouter := router.PathPrefix("/").Subrouter() rootRouter := router.PathPrefix("/").Subrouter()
apiRouter := router.PathPrefix("/api").Subrouter().StrictSlash(true) apiRouter := router.PathPrefix("/api").Subrouter().StrictSlash(true)
// https://github.com/gorilla/mux/issues/416
router.NotFoundHandler = router.NewRoute().BuildOnly().HandlerFunc(http.NotFound).GetHandler()
router.NotFoundHandler = middlewares.NewLoggingMiddleware(logbuch.Info, []string{
"/assets",
"/favicon",
"/service-worker.js",
})(router.NotFoundHandler)
// Globally used middlewares // Globally used middlewares
router.Use(middlewares.NewPrincipalMiddleware()) router.Use(middlewares.NewPrincipalMiddleware())
router.Use(middlewares.NewLoggingMiddleware(logbuch.Info, []string{"/assets"})) router.Use(middlewares.NewLoggingMiddleware(logbuch.Info, []string{"/assets"}))
@ -261,7 +269,7 @@ func listen(handler http.Handler) {
// UNIX domain socket // UNIX domain socket
if config.Server.ListenSocket != "" { if config.Server.ListenSocket != "" {
sSocket = &http.Server{ sSocket = &http.Server{
Handler: handler, Handler: handler,
ReadTimeout: 10 * time.Second, ReadTimeout: 10 * time.Second,
WriteTimeout: 10 * time.Second, WriteTimeout: 10 * time.Second,
} }