add basic logging middleware
tronnet/workflows: Static Analysis -- Golang / static-go (push) Failing after 28s
tronnet/workflows: Static Analysis -- Golang / static-go (push) Failing after 28s
This commit is contained in:
1 parent
35ecaf84e0
commit
8b73652c9b
1 file changed
+10
@@ -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))
|
||||||
|
})
|
||||||
|
}
|
||||||
Reference in new issue
Block a user