orama/invest-api/auth/context.go
anonpenguin23 655bd92178 Squashed 'website/' content from commit d19b985
git-subtree-dir: website
git-subtree-split: d19b98589ec5d235560a210b26195b653a65a808
2026-03-26 18:14:59 +02:00

26 lines
567 B
Go

package auth
import "context"
type contextKey string
const (
walletKey contextKey = "wallet"
chainKey contextKey = "chain"
)
func WithWallet(ctx context.Context, wallet, chain string) context.Context {
ctx = context.WithValue(ctx, walletKey, wallet)
ctx = context.WithValue(ctx, chainKey, chain)
return ctx
}
func WalletFromContext(ctx context.Context) (wallet, chain string, ok bool) {
w, wOk := ctx.Value(walletKey).(string)
c, cOk := ctx.Value(chainKey).(string)
if !wOk || !cOk || w == "" || c == "" {
return "", "", false
}
return w, c, true
}