push
circleci
1 of 47 new or added lines in 5 files covered. (2.13%)
1825 of 3611 relevant lines covered (50.54%)
2764.03 hits per line
| 1 |
package main
|
|
| 2 |
|
|
| 3 |
import (
|
|
| 4 |
"fmt"
|
|
| 5 |
"log"
|
|
| 6 |
"time"
|
|
| 7 |
|
|
| 8 |
"github.com/jeffotoni/quick/http/client"
|
|
| 9 |
) |
|
| 10 |
|
|
|
NEW
|
func main() {
|
× |
|
NEW
|
cClient := client.New( |
× |
|
NEW
|
client.WithTimeout(10*time.Second),
|
× |
|
NEW
|
client.WithHeaders(map[string]string{ |
× |
|
NEW
|
"Content-Type": "application/json", |
× |
|
NEW
|
}), |
× |
|
NEW
|
// Enabling retry
|
× |
|
NEW
|
client.WithRetry( |
× |
|
NEW
|
client.RetryConfig{
|
× |
|
NEW
|
MaxRetries: 2,
|
× |
|
NEW
|
Delay: 1 * time.Second,
|
× |
|
NEW
|
UseBackoff: true,
|
× |
|
NEW
|
Statuses: []int{500, 502, 503}, |
× |
|
NEW
|
FailoverURLs: []string{"http://hosterror", "https://httpbin.org/post"}, |
× |
|
NEW
|
EnableLog: true,
|
× |
|
NEW
|
}), |
× |
|
NEW
|
) |
× |
|
NEW
|
|
× |
|
NEW
|
// call POST
|
× |
|
NEW
|
resp, err := cClient.Post("https://httpbin_error.org/post", map[string]string{ |
× |
|
NEW
|
"name": "jeffotoni in action with Quick!!!", |
× |
|
NEW
|
}) |
× |
|
NEW
|
|
× |
|
NEW
|
if err != nil { |
× |
|
NEW
|
log.Fatalf("POST request failed: %v", err)
|
× |
|
NEW
|
} |
× |
|
NEW
|
fmt.Println("POST Form Response:", string(resp.Body)) |
× |
| 38 |
} |