t2/routes/path_middleware.go

16 lines
344 B
Go

package routes
import (
"context"
"net/http"
"gitea.henriburau.de/haw-lan/cod4watcher/views"
)
func PathMiddleware(next http.Handler) http.Handler {
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
ctx := context.WithValue(r.Context(), views.PathContext, r.URL.Path)
next.ServeHTTP(w, r.WithContext(ctx))
})
}