one http.Client for server instead of new per /ipcc
This commit is contained in:
@@ -38,6 +38,8 @@ type Server struct {
|
|||||||
httpd *http.Server
|
httpd *http.Server
|
||||||
xrpcc *xrpc.Client
|
xrpcc *xrpc.Client
|
||||||
cfg *Config
|
cfg *Config
|
||||||
|
|
||||||
|
ipccClient http.Client
|
||||||
}
|
}
|
||||||
|
|
||||||
type Config struct {
|
type Config struct {
|
||||||
@@ -105,6 +107,13 @@ func serve(cctx *cli.Context) error {
|
|||||||
ipccHost: ipccHost,
|
ipccHost: ipccHost,
|
||||||
staticCDNHost: staticCDNHost,
|
staticCDNHost: staticCDNHost,
|
||||||
},
|
},
|
||||||
|
ipccClient: http.Client{
|
||||||
|
Transport: &http.Transport{
|
||||||
|
TLSClientConfig: &tls.Config{
|
||||||
|
InsecureSkipVerify: true,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
// Create the HTTP server.
|
// Create the HTTP server.
|
||||||
@@ -584,15 +593,8 @@ func (srv *Server) WebIpCC(c echo.Context) error {
|
|||||||
}
|
}
|
||||||
ipccUrlBuilder.Path = "ipccdata.IpCcService/Lookup"
|
ipccUrlBuilder.Path = "ipccdata.IpCcService/Lookup"
|
||||||
ipccUrl := ipccUrlBuilder.String()
|
ipccUrl := ipccUrlBuilder.String()
|
||||||
cl := http.Client{
|
|
||||||
Transport: &http.Transport{
|
|
||||||
TLSClientConfig: &tls.Config{
|
|
||||||
InsecureSkipVerify: true,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
}
|
|
||||||
postBodyReader := bytes.NewReader(request)
|
postBodyReader := bytes.NewReader(request)
|
||||||
response, err := cl.Post(ipccUrl, "application/json", postBodyReader)
|
response, err := srv.ipccClient.Post(ipccUrl, "application/json", postBodyReader)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Warnf("ipcc backend error %s", err)
|
log.Warnf("ipcc backend error %s", err)
|
||||||
return c.JSON(500, IPCCResponse{})
|
return c.JSON(500, IPCCResponse{})
|
||||||
|
|||||||
Reference in New Issue
Block a user