GithubHelp home page GithubHelp logo

hakancelikdev / kong-plugin-response-transformer-extra Goto Github PK

View Code? Open in Web Editor NEW
4.0 2.0 0.0 40 KB

:shield: Kong plugin response transformer extra; Transformations can be restricted to responses with specific status codes using various config.*.if_status configuration parameters.

License: Apache License 2.0

Lua 100.00%
kong kong-api-gateway kong-gateway kong-plugin lua

kong-plugin-response-transformer-extra's Introduction

Kong plugin response transformer extra

Transformations can be restricted to responses with specific status codes using various config.*.if_status configuration parameters.

Extras

Priortiy

Priortiy: 902 Default 800 on kong. to make it work before the plugin response-ratelimiting response-ratelimiting's priorty is 900

if_status

Response Transformer Extra includes the following additional configurations: add.if_status, append.if_status, remove.if_status, replace.if_status and rename.if_status.

Config Type Description
config.remove.if_status [ Optional ] array of string elements List of response status codes or status code ranges to which the transformation will apply. Empty means all response codes.
config.rename.if_status [ Optional ] array of string elements List of response status codes or status code ranges to which the transformation will apply. Empty means all response codes.
config.replace.if_status [ Optional ] array of string elements List of response status codes or status code ranges to which the transformation will apply. Empty means all response codes.
config.add.if_status [ Optional ] array of string elements List of response status codes or status code ranges to which the transformation will apply. Empty means all response codes.
config.append.if_status [ Optional ] array of string elements List of response status codes or status code ranges to which the transformation will apply. Empty means all response codes.

NOTE: range feature is not implemented yet


Test with pongo

$ pongo run
$ pongo shell
$ kong migrations bootstrap --force
$ kong start

$ curl -i -X POST \
 --url http://localhost:8001/services/ \
 --data 'name=example-service' \
 --data 'url=http://konghq.com'

$ curl -i -X POST \
 --url http://localhost:8001/services/example-service/routes \
 --data 'hosts[]=example.com'

$ curl -X POST http://localhost:8001/services/example-service/plugins/ \
  --header 'content-type: application/json' \
  --data '{"name": "response-transformer-extra", "config": {"add": {"headers": ["h1:v2", "h2:v1"], "if_status": ["200", "301"]}}}'

$ curl -I -H "Host: example.com" http://localhost:8000/

Run tests with Pongo

$ pongo run

specific path, tests

$ pongo run -- ./spec/response-transformer-extra/01-header_transformer_spec.lua

kong-plugin-response-transformer-extra's People

Contributors

hakancelikdev avatar

Stargazers

 avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.