Skip to content

Commit

Permalink
Merge pull request #58 from nij4t/master
Browse files Browse the repository at this point in the history
Minor refactoring for better testability
  • Loading branch information
tiaguinho authored Jun 18, 2020
2 parents d44b69f + 837b5be commit 8cc3c3e
Showing 1 changed file with 4 additions and 7 deletions.
11 changes: 4 additions & 7 deletions wsdl.go
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ type xsdMaxInclusive struct {
Value string `xml:"value,attr"`
}

func getWsdlBody(u string, httpClient *http.Client) (reader io.ReadCloser, err error) {
func getWsdlBody(u string, c *http.Client) (reader io.ReadCloser, err error) {
parse, err := url.Parse(u)
if err != nil {
return nil, err
Expand All @@ -168,19 +168,16 @@ func getWsdlBody(u string, httpClient *http.Client) (reader io.ReadCloser, err e
}
return outFile, nil
}
if httpClient == nil {
httpClient = &http.Client{}
}
r, err := httpClient.Get(u)
r, err := c.Get(u)
if err != nil {
return nil, err
}
return r.Body, nil
}

// getWsdlDefinitions sent request to the wsdl url and set definitions on struct
func getWsdlDefinitions(u string, httpClient *http.Client) (wsdl *wsdlDefinitions, err error) {
reader, err := getWsdlBody(u, httpClient)
func getWsdlDefinitions(u string, c *http.Client) (wsdl *wsdlDefinitions, err error) {
reader, err := getWsdlBody(u, c)
if err != nil {
return nil, err
}
Expand Down

0 comments on commit 8cc3c3e

Please sign in to comment.