Added attribute proxy for mc admin config set ALIAS logger_webhook (#16657)

Signed-off-by: Shubhendu Ram Tripathi <shubhendu@minio.io>
This commit is contained in:
Shubhendu
2023-02-22 10:49:46 +05:30
committed by GitHub
parent 9202c6e26a
commit 6b65ba1551
3 changed files with 26 additions and 0 deletions

View File

@@ -24,6 +24,7 @@ import (
"errors"
"fmt"
"net/http"
"net/url"
"strings"
"sync"
"sync/atomic"
@@ -51,6 +52,7 @@ type Config struct {
ClientCert string `json:"clientCert"`
ClientKey string `json:"clientKey"`
QueueSize int `json:"queueSize"`
Proxy string `json:"string"`
Transport http.RoundTripper `json:"-"`
// Custom logger
@@ -127,6 +129,15 @@ func (h *Target) Init() error {
req.Header.Set("Authorization", h.config.AuthToken)
}
// If proxy available, set the same
if h.config.Proxy != "" {
proxyURL, _ := url.Parse(h.config.Proxy)
transport := h.config.Transport
ctransport := transport.(*http.Transport).Clone()
ctransport.Proxy = http.ProxyURL(proxyURL)
h.config.Transport = ctransport
}
client := http.Client{Transport: h.config.Transport}
resp, err := client.Do(req)
if err != nil {