Skip to content
New issue

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

Allow setting headers in HTTP transports #2590

Merged
merged 1 commit into from
Mar 24, 2023

Commits on Mar 22, 2023

  1. Allow setting headers in HTTP transports

    Currently gqlgen sets Content-Type header to 'application/json'. There's
    no easy way to change it or add additional headers.
    
    This commit adds struct variable ResponseHeaders that can hold any
    headers you want to be returned with response. It is standard
    `map[string][]string` variable.
    
    If user does not set this map, we default to the Content-Type
    header with 'application/json' value - nothing will be changed
    for existing users.
    
    Usage:
    
    as simple as:
    
    ```
    headers := map[string][]string{
        "Content-Type": {"application/json; charset: utf8"},
        "Other-Header": {"dummy-post-header","another-value"},
    }
    
    h.AddTransport(transport.POST{ResponseHeaders: headers})
    ```
    
    Added tests in transport/headers_test.go.
    RatkoR committed Mar 22, 2023
    Configuration menu
    Copy the full SHA
    65b4f32 View commit details
    Browse the repository at this point in the history