use logging middleware from common-lib
tronnet/workflows: Static Analysis -- Golang / static-go (push) Successful in 20s
tronnet/workflows: Static Analysis -- Golang / static-go (push) Successful in 20s
This commit is contained in:
1 parent
a13331e5a5
commit
1c82473c7f
2 files changed
+3
-13
No files matched your search
+2
-12
@@ -5,12 +5,10 @@ import (
|
||||
"fmt"
|
||||
"log"
|
||||
"net/http"
|
||||
paas "proxmoxaas-common-lib"
|
||||
"proxmoxaas-dashboard/app/common"
|
||||
"proxmoxaas-dashboard/app/routes"
|
||||
"proxmoxaas-dashboard/app/web"
|
||||
"time"
|
||||
|
||||
//"web" // go will complain here until the first build
|
||||
|
||||
"github.com/tdewolff/minify/v2"
|
||||
)
|
||||
@@ -45,7 +43,7 @@ func Run() {
|
||||
router.HandleFunc("GET /login", routes.HandleGETLogin)
|
||||
router.HandleFunc("GET /settings", routes.HandleGETSettings)
|
||||
|
||||
server := LoggingMiddleware(router)
|
||||
server := paas.LoggingMiddleware(router)
|
||||
|
||||
log.Printf("[INFO] starting server listening on 0.0.0.0:%d", common.Global.Port)
|
||||
log.Fatalf("[ERR ] starting gin router: %s", http.ListenAndServe(fmt.Sprintf("0.0.0.0:%d", common.Global.Port), server))
|
||||
@@ -62,11 +60,3 @@ 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))
|
||||
})
|
||||
}
|
||||
Reference in new issue
Block a user