...
1 package requestid
2
3 import (
4 "github.com/gin-gonic/gin"
5 )
6
7
8 type Option func(*config)
9
10 type (
11 Generator func() string
12 Handler func(c *gin.Context, requestID string)
13 )
14
15 type HeaderStrKey string
16
17
18 func WithGenerator(g Generator) Option {
19 return func(cfg *config) {
20 cfg.generator = g
21 }
22 }
23
24
25 func WithCustomHeaderStrKey(s HeaderStrKey) Option {
26 return func(cfg *config) {
27 cfg.headerKey = s
28 }
29 }
30
31
32 func WithHandler(handler Handler) Option {
33 return func(cfg *config) {
34 cfg.handler = handler
35 }
36 }
37
View as plain text