Added config options for http request timeouts

This commit is contained in:
2025-02-12 12:48:10 +11:00
parent e605e6437b
commit 1253c6499d
8 changed files with 91 additions and 4 deletions

18
middleware/start.go Normal file
View File

@@ -0,0 +1,18 @@
package middleware
import (
"net/http"
"projectreshoot/contexts"
"time"
)
func StartTimer(next http.Handler) http.Handler {
return http.HandlerFunc(
func(w http.ResponseWriter, r *http.Request) {
start := time.Now()
ctx := contexts.SetStart(r.Context(), start)
newReq := r.WithContext(ctx)
next.ServeHTTP(w, newReq)
},
)
}