Add graceful stopping to server, and extend middleware and pipeline logic

This commit is contained in:
Pablu23
2025-10-01 14:36:30 +02:00
parent 66f2811fff
commit 572e1177ef
5 changed files with 113 additions and 25 deletions

View File

@@ -9,7 +9,16 @@ import (
"github.com/urfave/negroni"
)
func RequestLogger(next http.Handler) http.Handler {
type RequestLogger struct{}
func (_ *RequestLogger) Stop() {
log.Info().Msg("Stopped Logging")
}
func (_ *RequestLogger) Manage() {
}
func (_ *RequestLogger) Use(next http.Handler) http.Handler {
log.Info().Msg("Enabling Logging")
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
start := time.Now()