// NewMiddleware creates middleware to set request to given context
// We are using this since we can't access http.Request directly from graphql resolver
NewMiddleware creates middleware to set request to given context
We are using this since we can't access http.Request directly from graphql resolver
// NewMiddleware creates middleware to set request to given context // We are using this since we can ' t access http . Request directly from graphql resolver
func NewMiddleware() func(next http.Handler) http.Handler {
	return func(next http.Handler) http.Handler {
		return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
			ctx := context.WithValue(r.Context(), ctxRequestKey{}, r)
			next.ServeHTTP(w, r.WithContext(ctx))
		})
	}
}
func NewMiddleware ( ) func ( next http . Handler ) http . Handler { return func ( next http . Handler ) http . Handler { return http . HandlerFunc ( func ( w http . ResponseWriter , r * http . Request ) { ctx := context . WithValue ( r . Context ( ) , ctxRequestKey { } , r ) next . ServeHTTP ( w , r . WithContext ( ctx ) ) } ) } }
NewMiddleware creates middleware to set request to given context
We are using this since we can't access http.Request directly from graphql resolver
NewMiddleware creates middleware to set request to given context We are using this since we can ' t access http . Request directly from graphql resolver