add middlewares, handlers and database models

This commit is contained in:
juancwu 2025-12-16 10:46:34 -05:00
commit 7e288ea67a
24 changed files with 1045 additions and 14 deletions

View file

@ -0,0 +1,15 @@
package middleware
import (
"net/http"
"git.juancwu.dev/juancwu/budgething/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))
})
}