mirror of
https://github.com/retailcrm/mg-transport-core.git
synced 2024-11-22 05:06:04 +03:00
godoc for HTTPClientBuilder
This commit is contained in:
parent
b1ac06c604
commit
cd5e0e1334
@ -16,7 +16,30 @@ var (
|
||||
DefaultTransport = http.DefaultTransport
|
||||
)
|
||||
|
||||
// HTTPClientBuilder builds http client with mocks (if necessary) and timeout
|
||||
// HTTPClientBuilder builds http client with mocks (if necessary) and timeout.
|
||||
// Example:
|
||||
// // Build HTTP client with timeout = 10 sec, without SSL certificates verification and with mocked google.com
|
||||
// client, err := NewHTTPClientBuilder().
|
||||
// SetTimeout(10).
|
||||
// SetMockAddress("api_mock:3004").
|
||||
// AddMockedDomain("google.com").
|
||||
// SetSSLVerification(false).
|
||||
// Build()
|
||||
//
|
||||
// if err != nil {
|
||||
// fmt.Print(err)
|
||||
// }
|
||||
//
|
||||
// // Actual response will be returned from "api_mock:3004" (it should provide any ssl certificate)
|
||||
// if resp, err := client.Get("https://google.com"); err == nil {
|
||||
// if data, err := ioutil.ReadAll(resp.Body); err == nil {
|
||||
// fmt.Printf("Data: %s", string(data))
|
||||
// } else {
|
||||
// fmt.Print(err)
|
||||
// }
|
||||
// } else {
|
||||
// fmt.Print(err)
|
||||
// }
|
||||
type HTTPClientBuilder struct {
|
||||
httpClient *http.Client
|
||||
httpTransport *http.Transport
|
||||
|
Loading…
Reference in New Issue
Block a user