Compare commits

..
2 Commits
Author SHA1 Message Date
alu e7341e3d9e remove go mod 2026-10-26 23:12:14 +00:00
alu 8b73652c9b add basic logging middleware
tronnet/workflows: Static Analysis -- Golang / static-go (push) Failing after 28s
2026-10-26 18:28:37 +00:00
2 changed files with 10 additions and 3 deletions

No files matched your search

-3
View File
@@ -1,3 +0,0 @@
module proxmoxaas-common-lib
go 1.26.0
+10
View File
@@ -4,7 +4,9 @@ import (
"bytes" "bytes"
"encoding/json" "encoding/json"
"html/template" "html/template"
"log"
"net/http" "net/http"
"time"
) )
func HTTPExecuteHTMLTemplate(w http.ResponseWriter, t *template.Template, name string, d any) { func HTTPExecuteHTMLTemplate(w http.ResponseWriter, t *template.Template, name string, d any) {
@@ -45,3 +47,11 @@ func HTTPWriteJson(w http.ResponseWriter, code int, obj any) {
return return
} }
} }
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))
})
}