We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
How do I achieve this? I wrote this middleware, turns out the middleware can't read gateway request headers.
forwardHeaderMiddleware := gateway.RequestMiddleware(func(r *http.Request) error { // Loop over header names for name, values := range r.Header { // Loop over all values for the name. for _, value := range values { r.Header.Set(name, value) } } return nil })
The text was updated successfully, but these errors were encountered:
Found the answer, the trick is using custom context value
forwardHeaderMiddleware := gateway.RequestMiddleware(func(r *http.Request) error { h := r.Context().Value(customContextKey).(http.Header) // Loop over header names for name, values := range r.Header { // Loop over all values for the name. for _, value := range values { r.Header.Set(name, value) } } return nil }) http.HandleFunc("/graphql", func(w http.ResponseWriter, r *http.Request) { r = r.WithContext(context.WithValue(r.Context(), customContextKey, r.Header)) gw.GraphQLHandler(w, r) })
Sorry, something went wrong.
No branches or pull requests
How do I achieve this? I wrote this middleware, turns out the middleware can't read gateway request headers.
The text was updated successfully, but these errors were encountered: