timezone.go 316 B

12345678910111213141516171819
  1. package timezone
  2. import (
  3. "github.com/gofiber/fiber/v2"
  4. )
  5. func New(config ...Config) fiber.Handler {
  6. cfg := defaultConfig(config...)
  7. return func(c *fiber.Ctx) (err error) {
  8. headers := c.GetReqHeaders()
  9. if tz, ok := headers[cfg.HeaderName]; ok {
  10. c.Locals(CtxTimezoneKey, tz)
  11. }
  12. return c.Next()
  13. }
  14. }