Refactor routing and middleware architecture

This commit is contained in:
bronku 2025-03-22 11:22:45 +01:00
parent 08d41b0348
commit fb97ba20c0
5 changed files with 62 additions and 51 deletions

16
logging/logger.go Normal file
View file

@ -0,0 +1,16 @@
package logging
import (
"fmt"
"net/http"
"time"
)
func Middleware(in http.Handler) http.Handler {
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
start := time.Now()
fmt.Println(r.Method, r.URL.String())
in.ServeHTTP(w, r)
fmt.Println(r.Method, "finished in", time.Since(start))
})
}