WithSource returns a copy of ctx carrying the given Source. Use this on the request context before invoking a downstream handler so [SourceFromContext] can recover it for logging.
(ctx context.Context, src Source)
| 19 | // request context before invoking a downstream handler so [SourceFromContext] |
| 20 | // can recover it for logging. |
| 21 | func WithSource(ctx context.Context, src Source) context.Context { |
| 22 | return context.WithValue(ctx, sourceCtxKey{}, src) |
| 23 | } |
| 24 | |
| 25 | // SourceFromContext returns the Source attached by [WithSource], or the empty |
| 26 | // string when no Source is set. |