FromContext returns the backend from a context.
(ctx context.Context)
| 7 | |
| 8 | // FromContext returns the backend from a context. |
| 9 | func FromContext(ctx context.Context) *Backend { |
| 10 | if b, ok := ctx.Value(ContextKey).(*Backend); ok { |
| 11 | return b |
| 12 | } |
| 13 | |
| 14 | return nil |
| 15 | } |
| 16 | |
| 17 | // WithContext returns a new context with the backend attached. |
| 18 | func WithContext(ctx context.Context, b *Backend) context.Context { |
no test coverage detected