From 73b58a843dab448b04fb9f9e7d59aa6593b00854 Mon Sep 17 00:00:00 2001 From: Arthur Lu Date: Fri, 23 Oct 2026 21:06:37 +0000 Subject: [PATCH] re-add logging middlware --- app/app.go | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/app/app.go b/app/app.go index c59db99..0d29f61 100644 --- a/app/app.go +++ b/app/app.go @@ -8,6 +8,7 @@ import ( "proxmoxaas-dashboard/app/common" "proxmoxaas-dashboard/app/routes" "proxmoxaas-dashboard/app/web" + "time" //"web" // go will complain here until the first build @@ -44,8 +45,10 @@ func Run() { router.HandleFunc("GET /login", routes.HandleGETLogin) router.HandleFunc("GET /settings", routes.HandleGETSettings) + server := LoggingMiddleware(router) + // run on all interfaces with port - log.Fatal("[ERR ] starting gin router: ", http.ListenAndServe(fmt.Sprintf("0.0.0.0:%d", common.Global.Port), router)) + log.Fatal("[ERR ] starting gin router: ", http.ListenAndServe(fmt.Sprintf("0.0.0.0:%d", common.Global.Port), server)) } // setup static resources under web (css, images, modules, scripts) @@ -59,3 +62,11 @@ func ServeStatic(router *http.ServeMux, m *minify.M) { w.Write([]byte(data.Data)) }) } + +func LoggingMiddleware(next http.Handler) http.Handler { + return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { + start := time.Now() + next.ServeHTTP(w, r) + log.Printf("%s %s %s", r.Method, r.URL.Path, time.Since(start)) + }) +}