GetRequestID retrieves the request ID from the context. Returns empty string if not found.
(ctx context.Context)
| 31 | // GetRequestID retrieves the request ID from the context. |
| 32 | // Returns empty string if not found. |
| 33 | func GetRequestID(ctx context.Context) string { |
| 34 | if ctx == nil { |
| 35 | return "" |
| 36 | } |
| 37 | if id, ok := ctx.Value(requestIDKey{}).(string); ok { |
| 38 | return id |
| 39 | } |
| 40 | return "" |
| 41 | } |
| 42 | |
| 43 | // SetGinRequestID stores the request ID in the Gin context. |
| 44 | func SetGinRequestID(c *gin.Context, requestID string) { |
no outgoing calls