This commit is contained in:
parent
9957ba8302
commit
271acc8d29
2 changed files with 20 additions and 0 deletions
17
web/public/middleware/SaveFullPath.go
Normal file
17
web/public/middleware/SaveFullPath.go
Normal file
|
@ -0,0 +1,17 @@
|
|||
package webmiddleware
|
||||
|
||||
import (
|
||||
"context"
|
||||
"net/http"
|
||||
)
|
||||
|
||||
const FullPathContextKey KeyType = "request-full-path"
|
||||
|
||||
func AppendFullPathMiddleware(h http.Handler) http.Handler {
|
||||
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
||||
h.ServeHTTP(
|
||||
w,
|
||||
r.WithContext(context.WithValue(r.Context(), FullPathContextKey, r.URL.Path)),
|
||||
)
|
||||
})
|
||||
}
|
3
web/public/middleware/keyType.go
Normal file
3
web/public/middleware/keyType.go
Normal file
|
@ -0,0 +1,3 @@
|
|||
package webmiddleware
|
||||
|
||||
type KeyType string
|
Loading…
Reference in a new issue