From a987526076c3b219db9b44b2e5876dc788658473 Mon Sep 17 00:00:00 2001 From: rorke Date: Wed, 15 Mar 2023 16:01:15 +0800 Subject: [PATCH] call uuid generator only if rid is empty --- middleware/requestid/requestid.go | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/middleware/requestid/requestid.go b/middleware/requestid/requestid.go index cc77803815..6e076282f1 100644 --- a/middleware/requestid/requestid.go +++ b/middleware/requestid/requestid.go @@ -16,7 +16,10 @@ func New(config ...Config) fiber.Handler { return c.Next() } // Get id from request, else we generate one - rid := c.Get(cfg.Header, cfg.Generator()) + rid := c.Get(cfg.Header) + if rid == "" { + rid = cfg.Generator() + } // Set new id to response header c.Set(cfg.Header, rid)