• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

jeffotoni / quick / 214

04 Mar 2025 07:11AM UTC coverage: 49.209% (-26.0%) from 75.221%
214

push

circleci

jeffotoni
Merge branch 'feature/refactory_http_client'

new version http client

32 of 1275 new or added lines in 44 files covered. (2.51%)

15 existing lines in 1 file now uncovered.

1803 of 3664 relevant lines covered (49.21%)

2724.12 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

0.0
/example/quick.http.client/full.methods.retry/main.go
1
package main
2

3
import (
4
        "context"
5
        "crypto/tls"
6
        "encoding/json"
7
        "fmt"
8
        "log"
9
        "time"
10

11
        "github.com/jeffotoni/quick/http/client"
12
)
13

NEW
14
func main() {
×
NEW
15

×
NEW
16
        // Example of creating an HTTP client using a fluent and modular approach.
×
NEW
17
        // This allows fine-grained control over HTTP settings without requiring a full config struct.
×
NEW
18
        //
×
NEW
19
        // - WithTimeout: Sets the HTTP client timeout to 30 seconds.
×
NEW
20
        // - WithDisableKeepAlives: Enables or disables HTTP keep-alives (false = keep-alives enabled).
×
NEW
21
        // - WithMaxIdleConns: Defines the maximum number of idle connections (20).
×
NEW
22
        // - WithMaxConnsPerHost: Sets the maximum connections allowed per host (20).
×
NEW
23
        // - WithMaxIdleConnsPerHost: Sets the maximum number of idle connections per host (20).
×
NEW
24
        // - WithContext: Injects a context for the client (context.TODO() used as placeholder).
×
NEW
25
        // - WithHeaders: Adds custom headers (e.g., Content-Type: application/xml).
×
NEW
26
        // - WithTLSConfig: Configures TLS settings, including InsecureSkipVerify and TLS version.
×
NEW
27
        // - WithRetry: Enables automatic retries for specific HTTP status codes (500, 502, 503, 504)
×
NEW
28
        //   with exponential backoff (2s-bex) and a maximum of 3 attempts.
×
NEW
29
        cClient := client.New(
×
NEW
30
                client.WithTimeout(5*time.Second),
×
NEW
31
                client.WithDisableKeepAlives(false),
×
NEW
32
                client.WithMaxIdleConns(20),
×
NEW
33
                client.WithMaxConnsPerHost(20),
×
NEW
34
                client.WithMaxIdleConnsPerHost(20),
×
NEW
35
                client.WithContext(context.TODO()),
×
NEW
36
                client.WithHeaders(map[string]string{"Content-Type": "application/xml"}),
×
NEW
37
                client.WithTLSConfig(&tls.Config{
×
NEW
38
                        InsecureSkipVerify: true,
×
NEW
39
                        MinVersion:         tls.VersionTLS12,
×
NEW
40
                }),
×
NEW
41
                client.WithRetry(
×
NEW
42
                        client.RetryConfig{
×
NEW
43
                                MaxRetries: 2,
×
NEW
44
                                Delay:      1 * time.Second,
×
NEW
45
                                UseBackoff: true,
×
NEW
46
                                Statuses:   []int{500},
×
NEW
47
                                EnableLog:  true,
×
NEW
48
                        }),
×
NEW
49
        )
×
NEW
50

×
NEW
51
        resp, err := cClient.Post("http://localhost:3000/v1/user", map[string]string{"message": "Hello, POST in Quick!"})
×
NEW
52
        if err != nil {
×
NEW
53
                log.Fatal(err)
×
NEW
54
        }
×
55

56
        // Unmarshal the JSON response (if applicable)
NEW
57
        var result map[string]string
×
NEW
58
        if err := json.Unmarshal(resp.Body, &result); err != nil {
×
NEW
59
                log.Fatal(err)
×
NEW
60
        }
×
NEW
61
        fmt.Println("POST response:", result["message"])
×
62
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc