forked from toolshed/abra
		
	
		
			
				
	
	
		
			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
 | |
| }
 |