Automatically add Content-Type: application/json header for GraphQL requests, unless a different Content-Type is already defined
This commit is contained in:
parent
4d186c6e71
commit
eee5bc8f9d
@ -17,6 +17,9 @@ import (
|
|||||||
const (
|
const (
|
||||||
// HostHeader is the name of the header used to specify the host
|
// HostHeader is the name of the header used to specify the host
|
||||||
HostHeader = "Host"
|
HostHeader = "Host"
|
||||||
|
|
||||||
|
// ContentTypeHeader is the name of the header used to specify the content type
|
||||||
|
ContentTypeHeader = "Content-Type"
|
||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
@ -87,6 +90,11 @@ func (service *Service) ValidateAndSetDefaults() {
|
|||||||
if len(service.Headers) == 0 {
|
if len(service.Headers) == 0 {
|
||||||
service.Headers = make(map[string]string)
|
service.Headers = make(map[string]string)
|
||||||
}
|
}
|
||||||
|
// Automatically add "Content-Type: application/json" header if there's no Content-Type set
|
||||||
|
// and service.GraphQL is set to true
|
||||||
|
if _, contentTypeHeaderExists := service.Headers[ContentTypeHeader]; !contentTypeHeaderExists && service.GraphQL {
|
||||||
|
service.Headers[ContentTypeHeader] = "application/json"
|
||||||
|
}
|
||||||
for _, alert := range service.Alerts {
|
for _, alert := range service.Alerts {
|
||||||
if alert.FailureThreshold <= 0 {
|
if alert.FailureThreshold <= 0 {
|
||||||
alert.FailureThreshold = 3
|
alert.FailureThreshold = 3
|
||||||
|
Loading…
x
Reference in New Issue
Block a user