Documentation ¶
Overview ¶
Current request context data.
`kong.ctx.shared`: A table that has the lifetime of the current request and is shared between all plugins. It can be used to share data between several plugins in a given request.
Values inserted in this table by a plugin will be visible by all other plugins. One must use caution when interacting with its values, as a naming conflict could result in the overwrite of data.
Usage: // Two plugins A and B, if plugin A has a higher priority than B's // (it executes before B), and plugin A is a Go plugin:
// plugin A PluginA.go
func (conf Config) Access(kong *pdk.PDK) { err := kong.Ctx.SetShared("hello world") if err != nil { kong.Log.Err(err) return } }
// plugin B handler.lua function plugin_b_handler:access(conf)
kong.log(kong.ctx.shared.foo) // "hello world"
end
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Ctx ¶
Holds this module's functions. Accessible as `kong.Ctx`
func (Ctx) GetSharedAny ¶
kong.Ctx.GetSharedAny() returns a value from the `kong.ctx.shared` request context table.
func (Ctx) GetSharedFloat ¶
kong.Ctx.GetSharedFloat() returns a float value from the `kong.ctx.shared` request context table.
func (Ctx) GetSharedString ¶
kong.Ctx.GetSharedString() returns a string value from the `kong.ctx.shared` request context table.