#73 setup password hashing with argin2id and update some infra
Some checks failed
Build Docker Image / Explore-Gitea-Actions (push) Failing after 59s

This commit is contained in:
Tim
2024-08-10 00:14:38 +02:00
parent 2f1b4fc8a7
commit 0df0e7f6f9
15 changed files with 139 additions and 344 deletions

30
api/middleware/logger.go Normal file
View File

@@ -0,0 +1,30 @@
package middleware
import (
"log"
"net/http"
"time"
)
type WrappedWriter struct {
http.ResponseWriter
StatusCode int
}
func (w *WrappedWriter) WriteHeader(code int) {
w.ResponseWriter.WriteHeader(code)
w.StatusCode = code
}
func Logging(next http.Handler) http.Handler {
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
start := time.Now()
wrapped := &WrappedWriter{
ResponseWriter: w,
StatusCode: http.StatusOK,
}
next.ServeHTTP(wrapped, r)
log.Println(r.RemoteAddr, wrapped.StatusCode, r.Method, r.URL.Path, time.Since(start))
})
}