Setting global config-data key value metadata for all APIs?

I want to set config_data that is global and not specific to a single api-definition, so that I can access this key-value metadata in a custom plugin.

You can bundle a config file with it and read that in the init phase.

func init() {
    configFileName := "/opt/tyk-plugins/plugin-config.json"

    // read the config file
    logger.Info("plugin: Loading config file: ", configFileName)
    configFile, err := os.Open(configFileName)
    defer configFile.Close()

Bear in mind that you can use this in combination with environment variables and even then use an API’s config data to override the config for a specific API.

Additionally, you can set a constant Gateway Environment Variable with key-value pair and access that in the custom plugin like so:

      - MY_CUSTOM_KEY="Hello"

And that can be accessed in your custom plugin with:

func init() {
	someValue := os.Getenv("MY_CUSTOM_KEY")
1 Like