one http.Client for server instead of new per /ipcc

(cherry picked from commit 22e1914f58)
This commit is contained in:
Brian Olson
2024-10-17 10:17:17 -04:00
committed by Hailey
parent 3229511849
commit 3fd8c06138
+10 -8
View File
@@ -38,6 +38,8 @@ type Server struct {
httpd *http.Server
xrpcc *xrpc.Client
cfg *Config
ipccClient http.Client
}
type Config struct {
@@ -105,6 +107,13 @@ func serve(cctx *cli.Context) error {
ipccHost: ipccHost,
staticCDNHost: staticCDNHost,
},
ipccClient: http.Client{
Transport: &http.Transport{
TLSClientConfig: &tls.Config{
InsecureSkipVerify: true,
},
},
},
}
// Create the HTTP server.
@@ -584,15 +593,8 @@ func (srv *Server) WebIpCC(c echo.Context) error {
}
ipccUrlBuilder.Path = "ipccdata.IpCcService/Lookup"
ipccUrl := ipccUrlBuilder.String()
cl := http.Client{
Transport: &http.Transport{
TLSClientConfig: &tls.Config{
InsecureSkipVerify: true,
},
},
}
postBodyReader := bytes.NewReader(request)
response, err := cl.Post(ipccUrl, "application/json", postBodyReader)
response, err := srv.ipccClient.Post(ipccUrl, "application/json", postBodyReader)
if err != nil {
log.Warnf("ipcc backend error %s", err)
return c.JSON(500, IPCCResponse{})