Skip to content
Snippets Groups Projects
Commit ee7af3f4 authored by Yordan Kinkov's avatar Yordan Kinkov
Browse files

Add custom http client

parent 2f7bbaab
Branches
Tags
No related merge requests found
......@@ -5,6 +5,7 @@ import (
"errors"
"fmt"
"log"
"net"
"net/http"
"time"
......@@ -106,7 +107,7 @@ func main() {
// Apply Authentication middleware if enabled
if cfg.Auth.Enabled {
m, err := auth.NewMiddleware(cfg.Auth.JwkURL, cfg.Auth.RefreshInterval, http.DefaultClient)
m, err := auth.NewMiddleware(cfg.Auth.JwkURL, cfg.Auth.RefreshInterval, httpClient())
if err != nil {
log.Fatalf("failed to create authentication middleware: %v", err)
}
......@@ -174,3 +175,19 @@ func exposeMetrics(addr string, logger *zap.Logger) {
logger.Error("error exposing prometheus metrics", zap.Error(err))
}
}
func httpClient() *http.Client {
return &http.Client{
Transport: &http.Transport{
Proxy: http.ProxyFromEnvironment,
DialContext: (&net.Dialer{
Timeout: 30 * time.Second,
}).DialContext,
MaxIdleConns: 100,
MaxIdleConnsPerHost: 100,
TLSHandshakeTimeout: 10 * time.Second,
IdleConnTimeout: 60 * time.Second,
},
Timeout: 30 * time.Second,
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment