Enabled indicates if a Feature is enabled in the Gate contained in ctx. It returns false when there is no Gate.
(ctx context.Context, f Feature)
| 124 | // Enabled indicates if a Feature is enabled in the Gate contained in ctx. It |
| 125 | // returns false when there is no Gate. |
| 126 | func Enabled(ctx context.Context, f Feature) bool { |
| 127 | gate, ok := ctx.Value(contextKey{}).(Gate) |
| 128 | return ok && gate.Enabled(f) |
| 129 | } |
| 130 | |
| 131 | // NewContext returns a copy of ctx containing gate. Check it using [Enabled]. |
| 132 | func NewContext(ctx context.Context, gate Gate) context.Context { |