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

jeffotoni / quick / 221

06 Mar 2025 07:12PM UTC coverage: 49.324% (-1.2%) from 50.54%
221

push

circleci

jeffotoni
Merge remote-tracking branch 'origin/example/http'

0 of 89 new or added lines in 3 files covered. (0.0%)

1825 of 3700 relevant lines covered (49.32%)

2697.54 hits per line

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

0.0
/example/quick.http.client/quick.delete/main.go
1
package main
2

3
import (
4
        "log"
5
        "time"
6

7
        "github.com/jeffotoni/quick"
8
        "github.com/jeffotoni/quick/http/client"
9
)
10

11
// Example HTTP request using Quick and an external API (reqres.in).
12
// This server listens on port 3000 and handles DELETE requests to delete user data on an external API.
13
// - WithTimeout: Sets the HTTP client timeout to 2 seconds.
14
// - WithHeaders: Adds custom headers for content type and authorization.
15

NEW
16
func main() {
×
NEW
17
        q := quick.New()
×
NEW
18

×
NEW
19
        // Define a DELETE endpoint to delete user data.
×
NEW
20
        q.Delete("/api/users/2", func(c *quick.Ctx) error {
×
NEW
21
                // Create an HTTP client with specific configurations.
×
NEW
22
                cClient := client.New(
×
NEW
23
                        client.WithTimeout(2*time.Second),
×
NEW
24
                        client.WithHeaders(map[string]string{
×
NEW
25
                                "Content-Type":  "application/json",
×
NEW
26
                                "Authorization": "Bearer EXAMPLE_TOKEN",
×
NEW
27
                        }),
×
NEW
28
                )
×
NEW
29

×
NEW
30
                // Perform a DELETE request to the external API.
×
NEW
31
                resp, err := cClient.Delete("https://reqres.in/api/users/2")
×
NEW
32
                if err != nil {
×
NEW
33
                        log.Println("DELETE Error:", err)
×
NEW
34
                        return c.Status(500).SendString("Failed to connect to external API")
×
NEW
35
                }
×
36

37
                // Log and return the response body from the external API.
NEW
38
                log.Println("DELETE Response:", string(resp.Body))
×
NEW
39
                return c.Status(resp.StatusCode).Send(resp.Body)
×
40
        })
41

42
        // Start listening on port 3000 for incoming HTTP requests.
NEW
43
        q.Listen(":3000")
×
44
}
45

46
// curl -X DELETE https://reqres.in/api/users/2 \
47
//       -H "Authorization: Bearer EXAMPLE_TOKEN"
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