Skip to content

Request Headers

Request Headers can either be set when creating a new client or when making a request.

Global

httpc := httpr.NewClient(
httpr.Header("Authorization", "some auth token"), // Set the Authorization header for all requests
httpr.Header("Accept", "application/json"), // Set the Accept header for all requests
)
resp, err := httpc.Get(context.Background(), "https://hehe.gov")

Per Request

httpc := httpr.NewClient()
resp, err := httpc.Get(context.Background(), "https://hehe.gov",
httpr.Header("X-Request-ID", "1234"),
httpr.Header("Accept", "application/json"),
)