Skip to content

Commit

Permalink
review: set method only when option is defined
Browse files Browse the repository at this point in the history
  • Loading branch information
kevinpollet committed Aug 4, 2022
1 parent 4557013 commit 10734f6
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
2 changes: 1 addition & 1 deletion docs/content/routing/services/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -330,7 +330,7 @@ Below are the available options for the health check mechanism:
- `timeout` (default: 5s), defines the maximum duration Traefik will wait for a health check request before considering the server unhealthy.
- `headers` (optional), defines custom headers to be sent to the health check endpoint.
- `followRedirects` (default: true), defines whether redirects should be followed during the health check calls.
- `method` (default: GET), defines the HTTP method that will be used while connecting to the endpoint.
- `method` (default: GET), defines the HTTP method that will be used while connecting to the endpoint.

!!! info "Interval & Timeout Format"

Expand Down
6 changes: 4 additions & 2 deletions pkg/healthcheck/healthcheck.go
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ func (b *BackendConfig) newRequest(serverURL *url.URL) (*http.Request, error) {
return http.NewRequest(http.MethodGet, u.String(), http.NoBody)
}

// setRequestOptions sets all request pertinent options present on the BackendConfig.
// setRequestOptions sets all request options present on the BackendConfig.
func (b *BackendConfig) setRequestOptions(req *http.Request) *http.Request {
if b.Options.Hostname != "" {
req.Host = b.Options.Hostname
Expand All @@ -112,7 +112,9 @@ func (b *BackendConfig) setRequestOptions(req *http.Request) *http.Request {
req.Header.Set(k, v)
}

req.Method = b.Options.Method
if b.Options.Method != "" {
req.Method = b.Options.Method
}

return req
}
Expand Down

0 comments on commit 10734f6

Please sign in to comment.