The Reedelk Transformer plugin transforms the upstream request body or downstream response body by invoking a Reedelk REST flow before hitting the upstream server, or before sending the downstream response back to the client. The plugin can apply both upstream and downstream transformations in the same flow.
Installation
Prerequisites
To use the Reedelk plugin for Kong, you must first install the Reedelk IntelliJ IDEA flow designer plugin using either of the following options:
-
IntelliJ Marketplace: Go to IntelliJ Preferences > Plugin > Marketplace, search for
Reedelk
, install the plugin, and restart IntelliJ. -
Manual install: From IntelliJ Preferences > Plugin > Settings icon > Install Plugin From Disk, and restart IntelliJ.
Install the Reedelk Transformer plugin
-
Clone the
kong-plugin-reedelk-transformer
:$ git clone https://github.com/reedelk/kong-plugin-reedelk-transformer.git $ cd kong-plugin-reedelk-transformer
-
Install the module
kong-plugin-reedelk-transformer
:$ luarocks install kong-plugin-reedelk-transformer-0.1.0-1.all.rock
-
Add the custom plugin to
kong.conf
:plugins = ...,reedelk-transformer
-
Restart Kong.
$ kong restart
Build and package the plugin
-
Clone the
kong-plugin-reedelk-transformer
:$ git clone https://github.com/reedelk/kong-plugin-reedelk-transformer.git $ cd kong-plugin-reedelk-transformer
-
Build the plugin locally (based on the
.rockspec
in the current directory):$ luarocks make
-
Package the plugin:
$ luarocks pack kong-plugin-reedelk-transformer 0.1.0-1
Hello World Example
This example uses a prepackaged kong-reedelk
Docker image with Kong and the
reedelk-transformer
plugin already installed. You can find the kong-reedelk
Docker images on
Docker Hub.
The kong-reedelk
image is preconfigured to use the following kong.yml
file,
which defines an upstream service mapped on Route http://localhost:8000/transform
and invokes a downstream transformer with the reedelk-transformer
plugin. The
configured downstream transformer integration flow URL is:
http://host.docker.internal:8282/api/message
Prerequisites
- Docker must be installed.
- IntelliJ IDEA IDE must be installed.
- Reedelk IntelliJ Flow Designer Plugin must be installed on your IntelliJ distribution.
Run the example
In the following steps, you run the kong-reedelk
docker image, and then create a
new Reedelk project that contains the integration flow invoked by the
downstream transformer.
-
Run the
kong-reedelk
Docker image:$ docker run -d --name kong-reedelk-transformer-plugin \ -p 8000:8000 \ -p 8443:8443 \ -p 127.0.0.1:8001:8001 \ -p 127.0.0.1:8444:8444 \ reedelk/kong-reedelk-transformer-plugin:latest
-
Make sure that Kong is up and running correctly with the
reedelk-transformer
plugin installed:$ curl http://localhost:8001/plugins
-
Open IntelliJ and create a new Reedelk project. The newly created project contains a
POST
Hello World flow to use as integration flow invoked by the downstream transformer. -
Start the new Reedelk project by clicking Play next to the Reedelk Runtime run configuration in IntelliJ.
-
Call the Kong Route with the following URL:
$ http://localhost:8000/transform
The result should be:
Hello World John
For more information about this example, including testing the IntelliJ Flow Designer Plugin workflow with Insomnia, see:
- Reedelk Getting Started documentation.
- Reedelk plugin documentation on GitHub.
- Kong Reedelk Transformer Plugin Demo video on Youtube.
Configuration Reference
This plugin is compatible with DB-less mode.
Example plugin configuration
Parameters
Here's a list of all the parameters which can be used in this plugin's configuration:
Form Parameter | Description |
---|---|
name
required Type: string |
The name of the plugin, in this case reedelk-transformer . |
service.name or service.id
Type: string |
The name or ID of the service the plugin targets.
Set one of these parameters if adding the plugin to a service through the top-level /plugins endpoint.
Not required if using /services/SERVICE_NAME|SERVICE_ID/plugins . |
route.name or route.id
Type: string |
The name or ID of the route the plugin targets.
Set one of these parameters if adding the plugin to a route through the top-level /plugins endpoint.
Not required if using /routes/ROUTE_NAME|ROUTE_ID/plugins . |
enabled
Type: boolean Default value: true |
Whether this plugin will be applied. |
config.upstream_transformer_url
optional |
The URL of the Reedelk REST flow endpoint to invoke for the upstream request transformation. |
config.downstream_transformer_url
optional |
The URL of the Reedelk REST flow endpoint to invoke for the downstream request transformation. |
The upstream_transformer_url
and downstream_transformer_url
are the URLs of the Reedelk REST flow endpoint to invoke for the upstream/downstream request/response transformations; e.g., http://localhost:8888/apiabledev/transform
.