add middlewares, handlers and database models
This commit is contained in:
parent
979a415b95
commit
7e288ea67a
24 changed files with 1045 additions and 14 deletions
15
internal/middleware/urlpath.go
Normal file
15
internal/middleware/urlpath.go
Normal 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))
|
||||
})
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue