RequestIDFromContext returns the request id stamped by the requestID middleware, or "" if none is present.
(ctx context.Context)
| 35 | // RequestIDFromContext returns the request id stamped by the requestID |
| 36 | // middleware, or "" if none is present. |
| 37 | func RequestIDFromContext(ctx context.Context) string { |
| 38 | if ctx == nil { |
| 39 | return "" |
| 40 | } |
| 41 | if id, ok := ctx.Value(requestIDKey).(string); ok { |
| 42 | return id |
| 43 | } |
| 44 | return "" |
| 45 | } |
| 46 | |
| 47 | // requestID middleware honors a caller-supplied X-Request-Id (so a trace id |
| 48 | // can flow across services) and otherwise mints one, then stashes it in the |
no outgoing calls
no test coverage detected