mirror of
https://github.com/syumai/workers.git
synced 2025-03-10 17:29:11 +00:00
Merge remote-tracking branch 'fork/service-bindings' into service-bindings
This commit is contained in:
commit
8b39614bbd
@ -2,6 +2,7 @@ package cloudflare
|
||||
|
||||
import (
|
||||
"context"
|
||||
"syscall/js"
|
||||
|
||||
"github.com/syumai/workers/cloudflare/internal/cfruntimecontext"
|
||||
)
|
||||
@ -12,3 +13,10 @@ import (
|
||||
func Getenv(ctx context.Context, name string) string {
|
||||
return cfruntimecontext.GetRuntimeContextEnv(ctx).Get(name).String()
|
||||
}
|
||||
|
||||
// GetBinding gets a value of an environment binding.
|
||||
// - https://developers.cloudflare.com/workers/platform/bindings/about-service-bindings/
|
||||
// - This function panics when a runtime context is not found.
|
||||
func GetBinding(ctx context.Context, name string) js.Value {
|
||||
return cfruntimecontext.GetRuntimeContextEnv(ctx).Get(name)
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user