PermalinkPDK
The Plugin Development Kit (PDK) is set of Lua functions and variables that can be used by plugins to implement their own logic.
The PDK is a Semantically Versioned component, originally released in Kong 0.14.0.
The PDK is guaranteed to be forward-compatible from its 1.0.0 release and onward.
The Plugin Development Kit is accessible from the kong
global variable,
and various functionalities are namespaced under this table, such as
kong.request
, kong.log
, etc.
Permalinkkong.version
A human-readable string containing the version number of the currently running node.
Usage
print(kong.version) -- "2.0.0"
Permalinkkong.version_num
An integral number representing the version number of the currently running node, useful for comparison and feature-existence checks.
Usage
if kong.version_num < 3004001 then -- 300.40.1 -> 3.4.1
-- no support for Routes & Services
end
Permalinkkong.configuration
A read-only table containing the configuration of the current Kong node, based on the configuration file and environment variables.
See kong.conf.default for details.
Comma-separated lists in the kong.conf
file get promoted to arrays of strings in this
table.
Usage
print(kong.configuration.prefix) -- "/usr/local/kong"
-- this table is read-only; the following throws an error:
kong.configuration.prefix = "foo"
Permalinkkong.db
Instance of Kong’s DAO (the kong.db
module). Contains accessor objects
to various entities.
A more thorough documentation of this DAO and new schema definitions is to be made available in the future.
Usage
kong.db.services:insert()
kong.db.routes:select()
Permalinkkong.dns
Instance of Kong’s DNS resolver, a client object from the lua-resty-dns-client module.
Note: Usage of this module is currently reserved to the core or to advanced users.
Permalinkkong.worker_events
Instance of Kong’s IPC module for inter-workers communication from the lua-resty-events module.
Note: Usage of this module is currently reserved to the core or to advanced users.
Permalinkkong.cluster_events
Instance of Kong’s cluster events module for inter-nodes communication.
Note: Usage of this module is currently reserved to the core or to advanced users.
Permalinkkong.cache
Instance of Kong’s database caching object, from the kong.cache
module.
Note: Usage of this module is currently reserved to the core or to advanced users.