mirror of
https://github.com/TwiN/gatus.git
synced 2025-01-22 13:58:58 +01:00
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 (
|
||||
// HostHeader is the name of the header used to specify the host
|
||||
HostHeader = "Host"
|
||||
|
||||
// ContentTypeHeader is the name of the header used to specify the content type
|
||||
ContentTypeHeader = "Content-Type"
|
||||
)
|
||||
|
||||
var (
|
||||
@ -87,6 +90,11 @@ func (service *Service) ValidateAndSetDefaults() {
|
||||
if len(service.Headers) == 0 {
|
||||
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 {
|
||||
if alert.FailureThreshold <= 0 {
|
||||
alert.FailureThreshold = 3
|
||||
|
Loading…
Reference in New Issue
Block a user