forked from toolshed/abra
.gitea
cli
cmd
pkg
app
autocomplete
catalogue
client
config
container
context
dns
envfile
formatter
git
integration
jsontable
limit
lint
log
recipe
secret
server
service
ssh
test
upstream
web
client.go
web.go
scripts
tests
.dockerignore
.drone.yml
.envrc.sample
.gitignore
.goreleaser.yml
AUTHORS.md
Dockerfile
LICENSE
Makefile
README.md
go.mod
go.sum
renovate.json
26 lines
661 B
Go
26 lines
661 B
Go
package web
|
|
|
|
import (
|
|
"fmt"
|
|
|
|
"coopcloud.tech/abra/pkg/log"
|
|
"github.com/hashicorp/go-retryablehttp"
|
|
)
|
|
|
|
// customLeveledLogger is custom logger with custom logger baked in
|
|
type customLeveledLogger struct {
|
|
retryablehttp.Logger
|
|
}
|
|
|
|
// Printf wires up our existing custom logger into the custom retryablehttp logger
|
|
func (l customLeveledLogger) Printf(msg string, args ...interface{}) {
|
|
log.Debugf(fmt.Sprintf(msg, args...))
|
|
}
|
|
|
|
// NewHTTPRetryClient instantiates a new http client with retries baked in
|
|
func NewHTTPRetryClient() *retryablehttp.Client {
|
|
retryClient := retryablehttp.NewClient()
|
|
retryClient.Logger = customLeveledLogger{}
|
|
return retryClient
|
|
}
|