mirror of
https://github.com/syumai/workers.git
synced 2025-03-10 09:27:08 +00:00
22 lines
732 B
Go
22 lines
732 B
Go
package cloudflare
|
|
|
|
import (
|
|
"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(name string) string {
|
|
return cfruntimecontext.MustGetRuntimeContextEnv().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(name string) js.Value {
|
|
return cfruntimecontext.MustGetRuntimeContextEnv().Get(name)
|
|
}
|