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

jeffotoni / quick / 297

28 Mar 2025 07:23PM UTC coverage: 51.038% (-0.2%) from 51.199%
297

push

circleci

jeffotoni
Example cusom middleware quick net/http native

0 of 42 new or added lines in 2 files covered. (0.0%)

3074 of 6023 relevant lines covered (51.04%)

1662.0 hits per line

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

0.0
/example/middleware/dynamic/main.go
1
package main
2

3
import (
4
        "log"
5
        "net/http"
6
        "time"
7

8
        "github.com/jeffotoni/quick"
9
        "github.com/jeffotoni/quick/internal/rand"
10
)
11

NEW
12
func main() {
×
NEW
13
        q := quick.New()
×
NEW
14

×
NEW
15
        // Trace-ID middleware
×
NEW
16
        q.Use(func(h http.Handler) http.Handler {
×
NEW
17
                return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
×
NEW
18
                        start := time.Now()
×
NEW
19
                        traceID := rand.TraceID() // internal quick
×
NEW
20

×
NEW
21
                        // Inject the Trace-ID into the request and response header
×
NEW
22
                        r.Header.Set("X-Trace-ID", traceID)
×
NEW
23
                        w.Header().Set("X-Trace-ID", traceID)
×
NEW
24

×
NEW
25
                        // Print simple log with Trace-ID
×
NEW
26
                        log.Printf("[Trace-ID: %s] -> Request start %s %s\n", traceID, r.Method, r.URL.Path)
×
NEW
27
                        h.ServeHTTP(w, r)
×
NEW
28
                        duration := time.Since(start)
×
NEW
29

×
NEW
30
                        log.Printf("[Trace-ID: %s] <- End of request duration:[(%v)]\n", traceID, duration)
×
NEW
31
                })
×
32
        })
33

NEW
34
        q.Get("/v1/user/:name", func(c *quick.Ctx) error {
×
NEW
35
                name := c.Param("name")
×
NEW
36
                c.Set("Content-Type", "application/json")
×
NEW
37
                return c.Status(200).JSON(quick.M{
×
NEW
38
                        "msg": name,
×
NEW
39
                })
×
NEW
40
        })
×
41

NEW
42
        q.Listen("0.0.0.0:8080")
×
43
}
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