chore: expose thoth in lib (#911)
Imports a patch previously exclusive to Botstopper. Signed-off-by: Xe Iaso <me@xeiaso.net>
This commit is contained in:
parent
26b6d8a91a
commit
9affd2edf4
17 changed files with 12 additions and 10 deletions
14
lib/thoth/context.go
Normal file
14
lib/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
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue