Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/pantsel/kong-middleman-plugin
A Kong plugin that enables you to make an extra HTTP POST request before calling an API.
https://github.com/pantsel/kong-middleman-plugin
Last synced: 2 months ago
JSON representation
A Kong plugin that enables you to make an extra HTTP POST request before calling an API.
- Host: GitHub
- URL: https://github.com/pantsel/kong-middleman-plugin
- Owner: pantsel
- License: mit
- Created: 2016-11-21T11:33:38.000Z (almost 8 years ago)
- Default Branch: master
- Last Pushed: 2020-04-15T11:54:48.000Z (over 4 years ago)
- Last Synced: 2024-05-07T12:10:37.134Z (5 months ago)
- Language: Lua
- Homepage:
- Size: 41 KB
- Stars: 156
- Watchers: 9
- Forks: 63
- Open Issues: 13
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Kong Middleman
A Kong plugin that enables an extra HTTP POST request before proxying the original.
## Description
In some cases, you may need to validate a request to a separate server or service using custom logic before Kong proxies it to your API.
Middleman enables you to do that by allowing you to make an extra HTTP request before calling an API endpoint.## Installation
### Development
Navigate to kong/plugins folder and clone this repo
$ cd /path/to/kong/plugins
$ git clone https://github.com/pantsel/kong-middleman-plugin middleman
$ cd middleman
$ luarocks make *.rockspecTo make Kong aware that it has to look for the middleman plugin, you'll have to add it to the custom_plugins property in your configuration file.
custom_plugins:
- middlemanRestart Kong and you're ready to go.
## luarocks
$ luarocks install middleman## Configuration
You can add the plugin on top of an API by executing the following request on your Kong server:
$ curl -X POST http://kong:8001/apis/{api}/plugins \
--data "name=middleman" \
--data "config.url=http://myserver.io/validate"
--data "config.response=table"
--data "config.timeout=10000"
--data "config.keepalive=60000"form parameter
default
description
name
The name of the plugin to use, in this case:
middleman
config.url
requiredThe URL to which the plugin will make a JSON
POST
request before proxying the original request.
config.response
requiredThe type of response the middleman service is going to respond with
config.timeout
Timeout (miliseconds) for the request to the URL specified above. Default value is 10000.
config.keepalive
Keepalive time (miliseconds) for the request to the URL specified above. Default value is 60000.
Middleman will execute a JSON
POST
request to the specifiedurl
with the following body:
Attribute
Description
body_data
The body of the original request
url_args
The url arguments of the original request
headers
The headers of the original request
In the scope of your own endpoint, you may validate any of these attributes and accept or reject the request according to your needs. If an HTTP response code of 299 or less is returned, the request is accepted. Any response code above 299 will cause the request to be rejected.
## Author
Panagis Tselentis## License
The MIT License (MIT)
=====================Copyright (c) 2015 Panagis Tselentis
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.