Skip to content

thatmattlove/go-vercel-edge-config

Repository files navigation

edgeconfig


Go library to interact with Vercel Edge Config.

Docs GitHub Workflow Status

Installation

go get -d github.com/thatmattlove/go-vercel-edge-config

Usage

Example Edge Config Store

{
  "key": "value"
}

Initialize the Client

options := &edgeconfig.ClientOptions{
    EdgeConfigToken: "your-edge-config-token",
    EdgeConfigID: "your-edge-config-id",
}
ec, err := edgeconfig.New(options)

// You can also initialize a client from a connection string:
ec, err := edgeconfig.NewFromConnectionString("https://edge-config.vercel.com/your_edge_config_id_here?token=your_edge_config_read_access_token_here")

Retrieve a Single Value by Key

ec.Item("key")
// value

Retrieve All Items as a Map

ec.Items()
// map[key:value]

Retrieve Edge Config Digest

ec.Digest()
// d53d0989fcf40382f6979a1cb069e70b477606a156cf8dc6c96a7154b6e79a29

Retrieve All Edge Configs

err := ec.API.Authenticate("your_vercel_api_token")
configs, err := ec.API.ListAllEdgeConfigs()
// returns a slice of edge configs

GitHub