https://github.com/kong/kong-python-pdk
Write Kong plugins in Python (Experimental)
https://github.com/kong/kong-python-pdk
Last synced: 5 months ago
JSON representation
Write Kong plugins in Python (Experimental)
- Host: GitHub
- URL: https://github.com/kong/kong-python-pdk
- Owner: Kong
- License: apache-2.0
- Created: 2020-01-04T03:00:01.000Z (almost 6 years ago)
- Default Branch: master
- Last Pushed: 2024-10-13T23:33:23.000Z (12 months ago)
- Last Synced: 2025-05-06T11:16:40.287Z (5 months ago)
- Language: Python
- Homepage:
- Size: 5.59 MB
- Stars: 48
- Watchers: 105
- Forks: 15
- Open Issues: 23
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
# kong-python-pluginserver
[](https://badge.fury.io/py/kong-pdk)
Plugin server and PDK (Plugin Development Kit) for Python language support in Kong.
Requires Kong >= 2.3.0.
## Documentation
See in [Kong Docs](https://docs.konghq.com/gateway/latest/plugin-development/pluginserver/python/)
## Install the plugin server
```shell
pip3 install kong-pdk
```## Usage
```
usage: kong-python-pluginserver [-h] [-p prefix] [-v] [--version] [--socket-name SOCKET_NAME] [--listen-queue-size LISTEN_QUEUE_SIZE]
[--no-lua-style] [-m | -g] -d directory [--dump-plugin-info name] [--dump-all-plugins]Kong Python Plugin Server.
optional arguments:
-h, --help show this help message and exit
-p prefix, --kong-prefix prefix, -kong-prefix prefix
unix domain socket path to listen (default: /usr/local/kong/)
-v, --verbose turn on verbose logging (default: 1)
--version, -version show program's version number and exit
--socket-name SOCKET_NAME
socket name to listen on (default: python_pluginserver.sock)
--listen-queue-size LISTEN_QUEUE_SIZE
socket listen queue size (default: 4096)
--no-lua-style turn off Lua-style "data, err" return values for PDK functions and throw exception instead (default: False)
-m, --multiprocessing
enable multiprocessing (default: False)
-g, --gevent enable gevent (default: False)
-d directory, --plugins-directory directory, -plugins-directory directory
plugins directory
--dump-plugin-info name, -dump-plugin-info name
dump specific plugin info into stdout
--dump-all-plugins, -dump-all-plugins
dump all plugins info into stdout
```## PDK API reference
The PDK (plugin developemet kit) API document can be viewed [here](https://kong.github.io/kong-python-pdk/).
Reference is generated by Sphinx under `doc` folder and published to the `gh-pages` branch.
To generate updated docs, use:
```
git worktree add docs/build/html gh-pages
cd docs
make deps && make html
```## Deprecation Notice
In next major release of Kong Python PDK, return values will default to use Python style error handling instead of
Lua style. The new style API can be turned on now with `--no-lua-style`.```python
# old lua-style PDK API
host, err = kong.request.get_header("host")
if err:
pass # error handling# new python-style PDK API
try:
host = kong.request.get_header("host")
# no err in return, instead they are thrown if any
except Exception as ex:
pass # error handling
```## TODO
- Tests
- Hot reload