Use trust center from context
Signed-off-by: Émile Ré <emile@getprobo.com>
This commit is contained in:
@@ -59,7 +59,9 @@ func NewHandler[S graphql.ExecutableSchema](executableSchema S, logger *log.Logg
|
||||
}
|
||||
|
||||
func (gqlh *Handler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
|
||||
gqlh.gqlhandler.ServeHTTP(w, r)
|
||||
ctx := WithHTTPContext(r.Context(), w, r)
|
||||
|
||||
gqlh.gqlhandler.ServeHTTP(w, r.WithContext(ctx))
|
||||
}
|
||||
|
||||
func (gqlh *Handler) Use(extension graphql.HandlerExtension) {
|
||||
|
||||
@@ -28,16 +28,6 @@ var (
|
||||
httpRequestKey = &ctxKey{name: "http_request"}
|
||||
)
|
||||
|
||||
func HTTPContextMiddleware(next http.Handler) http.Handler {
|
||||
return http.HandlerFunc(
|
||||
func(w http.ResponseWriter, r *http.Request) {
|
||||
ctx := WithHTTPContext(r.Context(), w, r)
|
||||
|
||||
next.ServeHTTP(w, r.WithContext(ctx))
|
||||
},
|
||||
)
|
||||
}
|
||||
|
||||
func WithHTTPContext(ctx context.Context, w http.ResponseWriter, r *http.Request) context.Context {
|
||||
|
||||
ctx = context.WithValue(ctx, httpResponseWriterKey, w)
|
||||
|
||||
Reference in New Issue
Block a user