mirror of
https://github.com/TecharoHQ/anubis.git
synced 2026-04-10 10:38:45 +00:00
feat(thoth): store a thoth client in a context
Signed-off-by: Xe Iaso <me@xeiaso.net>
This commit is contained in:
14
internal/thoth/context.go
Normal file
14
internal/thoth/context.go
Normal file
@@ -0,0 +1,14 @@
|
||||
package thoth
|
||||
|
||||
import "context"
|
||||
|
||||
type ctxKey struct{}
|
||||
|
||||
func With(ctx context.Context, cli *Client) context.Context {
|
||||
return context.WithValue(ctx, ctxKey{}, cli)
|
||||
}
|
||||
|
||||
func FromContext(ctx context.Context) (*Client, bool) {
|
||||
cli, ok := ctx.Value(ctxKey{}).(*Client)
|
||||
return cli, ok
|
||||
}
|
||||
Reference in New Issue
Block a user