The Request Transformer plugin transforms the request sent by a client on the fly in Kong, before hitting the upstream server. Give it a try and discuss it here!
Can we customize the plugin to dynamically parse and change the upstream headers while serving?
The use case is when a client hits kong it would send a custom token which needs to parsed and appended to header while serving upstream URL. If possible can someone help how to do that since I am new to kong it would be helpful if someone can point to right document or link to proceed further?
Sure, you can fork the request-transformer and create your own. Here is Plugin Developer Guide:
Here are the sources for the Request Transformer Plugin:
https://github.com/Kong/kong/tree/master/kong/plugins/request-transformer
And here is the test suite:
https://github.com/Kong/kong/tree/master/spec/03-plugins/15-request-transformer
Are there any variables available to the request-transformer plugin during execution? For example upstream service name, request path? I had a look at the docs, but I could only see configuration for setting static values.
Request transformer currently only supports static values AFAIK.
Kong Enterprise Edition’s request-transformer-advanced
plugin supports something like you describe @Karthik_B
https://github.com/pearsontechnology/kong-rewrite-plugin might be what you are looking for. It allows you to basically script everything that the request-transformer and response-transformer do. We open sourced it a while back and use it daily in our environment, so while it may look stagnant it is actively maintained just very stable.
Thanks all, appreciate the feedback. The service/route concept has really helped pushing requests into upstream services more seamlessly.
Does the request-transformer plugin or the kong-rewrite-plugin allow transforming the Host: header of a request?
You should be able to add/update/remove any header with either plugin.