1
0
mirror of https://github.com/gofiber/fiber.git synced 2025-02-23 21:43:48 +00:00

support config RequestIDConfig param in RequestID()

This commit is contained in:
kiyon 2020-07-04 10:52:18 +08:00
parent 0369495888
commit a1fefd3f44

View File

@ -43,6 +43,7 @@ RequestID adds an UUID indentifier to the request, the following config argument
- RequestID(next func(*fiber.Ctx) bool) - RequestID(next func(*fiber.Ctx) bool)
- RequestID(header string) - RequestID(header string)
- RequestID(generator func() string) - RequestID(generator func() string)
- RequestID(config RequestIDConfig)
*/ */
func RequestID(options ...interface{}) fiber.Handler { func RequestID(options ...interface{}) fiber.Handler {
// Create default config // Create default config
@ -57,8 +58,10 @@ func RequestID(options ...interface{}) fiber.Handler {
config.Header = opt config.Header = opt
case func() string: case func() string:
config.Generator = opt config.Generator = opt
case RequestIDConfig:
config = opt
default: default:
log.Fatal("RequestID: the following option types are allowed: `string`, `func() string`") log.Fatal("RequestID: the following option types are allowed: `string`, `func() string`, `func(*fiber.Ctx) bool`, `RequestIDConfig`")
} }
} }
} }