17 lines
360 B
Go
17 lines
360 B
Go
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)),
|
|
)
|
|
})
|
|
}
|