mirror of
https://github.com/syumai/workers.git
synced 2025-03-10 17:29:11 +00:00
23 lines
783 B
Go
23 lines
783 B
Go
package cloudflare
|
|
|
|
import (
|
|
"context"
|
|
"syscall/js"
|
|
|
|
"github.com/syumai/workers/cloudflare/internal/cfruntimecontext"
|
|
)
|
|
|
|
// Getenv gets a value of an environment variable.
|
|
// - https://developers.cloudflare.com/workers/platform/environment-variables/
|
|
// - This function panics when a runtime context is not found.
|
|
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)
|
|
}
|