Support adding custom plaintext headers to downstream requests (#314)

This commit is contained in:
Felix Boers
2018-04-14 07:41:12 +02:00
committed by Tom Pallister
parent b46ef1945d
commit fa09e4cf7a
14 changed files with 376 additions and 183 deletions

View File

@ -1,15 +1,31 @@
Headers Transformation
=====================
======================
Ocelot allows the user to transform headers pre and post downstream request. At the moment Ocelot only supports find and replace. This feature was requested `GitHub #190 <https://github.com/TomPallister/Ocelot/issues/190>`_ and I decided that it was going to be useful in various ways.
Add to Request
^^^^^^^^^^^^^^
This feature was requestes in `GitHub #313 <https://github.com/ThreeMammals/Ocelot/issues/313>`_.
If you want to add a header to your upstream request please add the following to a ReRoute in your configuration.json:
.. code-block:: json
"UpstreamHeaderTransform": {
"Uncle": "Bob"
}
In the example above a header with the key Uncle and value Bob would be send to to the upstream service.
Placeholders are supported too (see below).
Add to Response
^^^^^^^^^^^^^^^
This feature was requested in `GitHub #280 <https://github.com/TomPallister/Ocelot/issues/280>`_. I have only implemented
for responses but could add for requests in the future.
This feature was requested in `GitHub #280 <https://github.com/TomPallister/Ocelot/issues/280>`_.
If you want to add a header to your downstream response please add the following to a ReRoute in configuration.json..
If you want to add a header to your downstream response please add the following to a ReRoute in configuration.json.
.. code-block:: json
@ -50,7 +66,7 @@ Add the following to a ReRoute in configuration.json in order to replace http://
},
Post Downstream Request
^^^^^^^^^^^^^^^^^^^^^^
^^^^^^^^^^^^^^^^^^^^^^^
Add the following to a ReRoute in configuration.json in order to replace http://www.bbc.co.uk/ with http://ocelot.com/. This transformation will take place after Ocelot has received the response from the downstream service.