re-add logging middlware
tronnet/workflows: Static Analysis -- Golang / static-go (push) Successful in 14s

This commit is contained in:
alu committed 2026-10-23 21:06:37 +00:00
1 parent e0ef1b598b
commit 73b58a843d
1 file changed
+12 -1
+12 -1
View File
@@ -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))
})
}