feat: add NewContext helper (by AI)
This commit is contained in:
parent
a81fb32f78
commit
b82e66e596
8
jsmod.go
8
jsmod.go
@ -20,6 +20,14 @@ func Get(ctx context.Context, key string) any {
|
||||
return nil
|
||||
}
|
||||
|
||||
// NewContext returns a new context with the provided injection map.
|
||||
func NewContext(parent context.Context, injects map[string]any) context.Context {
|
||||
if parent == nil {
|
||||
parent = context.Background()
|
||||
}
|
||||
return context.WithValue(parent, internalContextKey, injects)
|
||||
}
|
||||
|
||||
// IsSafeMode checks if the provided context indicates that the execution is in safe mode.
|
||||
func IsSafeMode(ctx context.Context) bool {
|
||||
if sm, ok := Get(ctx, "SafeMode").(bool); ok {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user