Files
2024-04-02 15:13:13 +03:00

37 lines
694 B
Go

package requestid
import (
"git.company.lan/gopkg/gin"
)
// Option for queue system
type Option func(*config)
type (
Generator func() string
Handler func(c *gin.Context, requestID string)
)
type HeaderStrKey string
// WithGenerator set generator function
func WithGenerator(g Generator) Option {
return func(cfg *config) {
cfg.generator = g
}
}
// WithCustomHeaderStrKey set custom header key for request id
func WithCustomHeaderStrKey(s HeaderStrKey) Option {
return func(cfg *config) {
cfg.headerKey = s
}
}
// WithHandler set handler function for request id with context
func WithHandler(handler Handler) Option {
return func(cfg *config) {
cfg.handler = handler
}
}