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,19 @@
package middleware
import (
"net/http"
"git.juancwu.dev/juancwu/budgething/internal/config"
"git.juancwu.dev/juancwu/budgething/internal/ctxkeys"
)
// Config middleware adds the sanitized app configuration to the request context.
// Sensitive values like JWTSecret and DBPath are excluded for security.
func Config(cfg *config.Config) func(http.Handler) http.Handler {
return func(next http.Handler) http.Handler {
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
ctx := ctxkeys.WithConfig(r.Context(), cfg.Sanitized())
next.ServeHTTP(w, r.WithContext(ctx))
})
}
}