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

mishankov / platforma / 18913451776

29 Oct 2025 03:34PM UTC coverage: 23.423% (+2.9%) from 20.552%
18913451776

Pull #14

github

mishankov
Add HandlerGroup test case

The test case verifies that HandlerGroup can be registered at a specific
path prefix and that requests are properly routed to handlers within the
group.
Pull Request #14: Httpserver cleanup

4 of 9 new or added lines in 4 files covered. (44.44%)

4 existing lines in 1 file now uncovered.

260 of 1110 relevant lines covered (23.42%)

0.27 hits per line

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

0.0
/httpserver/traceid.go
1
package httpserver
2

3
import (
4
        "context"
5
        "net/http"
6

7
        "github.com/mishankov/platforma/log"
8

9
        "github.com/google/uuid"
10
)
11

12
// TraceIdMiddleware is a middleware that adds a trace ID to the request context and response headers.
13
type TraceIdMiddleware struct {
14
        contextKey any
15
        header     string
16
}
17

18
// NewTraceIdMiddleware returns a new TraceId middleware.
19
// If key is nil, log.TraceIdKey is used.
20
// If header is empty, "Platforma-Trace-Id" is used.
NEW
21
func NewTraceIdMiddleware(contextKey any, header string) *TraceIdMiddleware {
×
22
        if contextKey == nil {
×
23
                contextKey = log.TraceIdKey
×
24
        }
×
25

26
        if header == "" {
×
27
                header = "Platforma-Trace-Id"
×
28
        }
×
29

NEW
30
        return &TraceIdMiddleware{contextKey: contextKey, header: header}
×
31
}
32

NEW
33
func (m *TraceIdMiddleware) Wrap(h http.Handler) http.Handler {
×
34
        return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
×
35
                traceId := uuid.NewString()
×
36
                ctx := context.WithValue(r.Context(), m.contextKey, traceId)
×
37
                r = r.WithContext(ctx)
×
38

×
39
                w.Header().Set(m.header, traceId)
×
40

×
41
                h.ServeHTTP(w, r)
×
42
        })
×
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