budgit/internal/middleware/urlpath.go
2025-12-16 10:50:16 -05:00

15 lines
393 B
Go

package middleware
import (
"net/http"
"git.juancwu.dev/juancwu/budgit/internal/ctxkeys"
)
// WithURLPath adds the current URL's path to the context
func WithURLPath(next http.Handler) http.Handler {
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
ctxWithPath := ctxkeys.WithURLPath(r.Context(), r.URL.Path)
next.ServeHTTP(w, r.WithContext(ctxWithPath))
})
}