External httpClient support

This commit is contained in:
kikimor
2021-02-24 21:47:09 +05:00
parent 6a2c796805
commit 51ae55e8a0
6 changed files with 47 additions and 89 deletions

View File

@@ -3,13 +3,10 @@ package networking
import (
"bytes"
"net/http"
"time"
)
// SendSoap send soap message
func SendSoap(endpoint, message string) (*http.Response, error) {
httpClient := new(http.Client)
func SendSoap(httpClient *http.Client, endpoint, message string) (*http.Response, error) {
resp, err := httpClient.Post(endpoint, "application/soap+xml; charset=utf-8", bytes.NewBufferString(message))
if err != nil {
return resp, err
@@ -17,12 +14,3 @@ func SendSoap(endpoint, message string) (*http.Response, error) {
return resp, nil
}
// SendSoapWithTimeout send soap message with timeOut
func SendSoapWithTimeout(endpoint string, message []byte, timeout time.Duration) (*http.Response, error) {
httpClient := &http.Client{
Timeout: timeout,
}
return httpClient.Post(endpoint, "application/soap+xml; charset=utf-8", bytes.NewReader(message))
}