...

Source file src/github.com/gin-contrib/requestid/options.go

Documentation: github.com/gin-contrib/requestid

     1  package requestid
     2  
     3  import (
     4  	"github.com/gin-gonic/gin"
     5  )
     6  
     7  // Option for queue system
     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  // WithGenerator set generator function
    18  func WithGenerator(g Generator) Option {
    19  	return func(cfg *config) {
    20  		cfg.generator = g
    21  	}
    22  }
    23  
    24  // WithCustomeHeaderStrKey set custom header key for request id
    25  func WithCustomHeaderStrKey(s HeaderStrKey) Option {
    26  	return func(cfg *config) {
    27  		cfg.headerKey = s
    28  	}
    29  }
    30  
    31  // WithHandler set handler function for request id with context
    32  func WithHandler(handler Handler) Option {
    33  	return func(cfg *config) {
    34  		cfg.handler = handler
    35  	}
    36  }
    37  

View as plain text