refactor: changed file structure
This commit is contained in:
18
internal/middleware/start.go
Normal file
18
internal/middleware/start.go
Normal file
@@ -0,0 +1,18 @@
|
||||
package middleware
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
"projectreshoot/pkg/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)
|
||||
},
|
||||
)
|
||||
}
|
||||
Reference in New Issue
Block a user