NewContextWithCache returns a derived context with a rights cache. This should only be used for request contexts.
(ctx context.Context)
| 166 | // NewContextWithCache returns a derived context with a rights cache. |
| 167 | // This should only be used for request contexts. |
| 168 | func NewContextWithCache(ctx context.Context) context.Context { |
| 169 | return context.WithValue(ctx, rightsCacheKey, &Rights{}) |
| 170 | } |
| 171 | |
| 172 | func cacheInContext(ctx context.Context, f func(*Rights)) { |
| 173 | if rights, ok := ctx.Value(rightsCacheKey).(*Rights); ok { |