Commit 16f92137 authored by Ivar Derksen's avatar Ivar Derksen
Browse files

Refactor: remove code duplication in making new retryablehttp client

parent e64f44dc
......@@ -72,8 +72,7 @@ func runHealthCheck(check HealthCheck) *issueEntry {
var intermediateIssue *issueEntry
client := retryablehttp.NewClient()
client.HTTPClient.Timeout = 3 * time.Second
client := newHTTPClient()
client.CheckRetry = func(ctx context.Context, resp *http.Response, respErr error) (bool, error) {
retry, err2 := retryablehttp.DefaultRetryPolicy(ctx, resp, respErr)
if !retry {
......
......@@ -20,8 +20,6 @@ import (
"sync"
"time"
"github.com/hashicorp/go-retryablehttp"
irma "github.com/privacybydesign/irmago"
"github.com/ashwanthkumar/slack-go-webhook"
......@@ -369,9 +367,7 @@ func checkCertificateExpiry() (ret issueEntries) {
func checkCertificateExpiryOf(url string) (ret issueEntries) {
log.Printf(" checking certificate expiry on %s", url)
// Use retryablehttp to prevent false positives.
client := retryablehttp.NewClient()
client.HTTPClient.Timeout = 3 * time.Second
client := newHTTPClient()
resp, err := client.Head(url)
if err != nil {
ret = append(ret, issueEntry{danger, fmt.Sprintf("%s: error %s", url, err)})
......
package main
import (
"github.com/hashicorp/go-retryablehttp"
"time"
)
func newHTTPClient() *retryablehttp.Client {
// Use retryablehttp to prevent false positives.
client := retryablehttp.NewClient()
client.HTTPClient.Timeout = 3 * time.Second
return client
}
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment