mirror of
https://github.com/fosrl/newt.git
synced 2026-05-18 22:29:53 +00:00
Merge pull request #331 from fosrl/dev
Follow redirects by default for backward compat
This commit is contained in:
@@ -47,7 +47,7 @@ type Config struct {
|
|||||||
Interval int `json:"hcInterval"` // in seconds
|
Interval int `json:"hcInterval"` // in seconds
|
||||||
UnhealthyInterval int `json:"hcUnhealthyInterval"` // in seconds
|
UnhealthyInterval int `json:"hcUnhealthyInterval"` // in seconds
|
||||||
Timeout int `json:"hcTimeout"` // in seconds
|
Timeout int `json:"hcTimeout"` // in seconds
|
||||||
FollowRedirects bool `json:"hcFollowRedirects"`
|
FollowRedirects *bool `json:"hcFollowRedirects"`
|
||||||
Headers map[string]string `json:"hcHeaders"`
|
Headers map[string]string `json:"hcHeaders"`
|
||||||
Method string `json:"hcMethod"`
|
Method string `json:"hcMethod"`
|
||||||
Status int `json:"hcStatus"` // HTTP status code
|
Status int `json:"hcStatus"` // HTTP status code
|
||||||
@@ -202,7 +202,9 @@ func (m *Monitor) addTargetUnsafe(config Config) error {
|
|||||||
cancel: cancel,
|
cancel: cancel,
|
||||||
client: &http.Client{
|
client: &http.Client{
|
||||||
CheckRedirect: func() func(*http.Request, []*http.Request) error {
|
CheckRedirect: func() func(*http.Request, []*http.Request) error {
|
||||||
if !config.FollowRedirects {
|
// Default to following redirects if not explicitly configured
|
||||||
|
followRedirects := config.FollowRedirects == nil || *config.FollowRedirects
|
||||||
|
if !followRedirects {
|
||||||
return func(req *http.Request, via []*http.Request) error {
|
return func(req *http.Request, via []*http.Request) error {
|
||||||
return http.ErrUseLastResponse
|
return http.ErrUseLastResponse
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user