refactor(middlewares,router): follow http package structure and interfaces

This commit is contained in:
Gustavo "Guz" L. de Mello
2024-07-22 11:24:14 -03:00
parent 294b943353
commit 9dd4681857
9 changed files with 182 additions and 117 deletions

View File

@@ -0,0 +1,21 @@
package middlewares
import (
"log"
"net/http"
)
type DevelopmentMiddleware struct {
Logger *log.Logger
}
func (m DevelopmentMiddleware) Serve(handler http.HandlerFunc) http.HandlerFunc {
return func(w http.ResponseWriter, r *http.Request) {
m.Logger.Printf("New request: %s", r.URL.Path)
handler(w, r)
w.Header().Del("Cache-Control")
w.Header().Add("Cache-Control", "max-age=0")
}
}