mirror of
https://codeberg.org/VnPower/PixivFE
synced 2024-12-06 19:16:23 +01:00
079993e801
Rename package handlers to middleware, since most are middleware router.go is not middleware. can be moved out to router/router.go
16 lines
431 B
Go
16 lines
431 B
Go
package middleware
|
|
|
|
import (
|
|
"net/http"
|
|
|
|
"codeberg.org/vnpower/pixivfe/v2/server/request_context"
|
|
)
|
|
|
|
// ProvideUserContext is a middleware that wraps an http.Handler
|
|
// to inject a user context into each incoming request.
|
|
func ProvideUserContext(h http.Handler) http.Handler {
|
|
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
|
h.ServeHTTP(w, r.WithContext(request_context.ProvideWith(r.Context())))
|
|
})
|
|
}
|