|
1 |
| -Method Transformation |
2 |
| -===================== |
| 1 | +Method Transformation [#f1]_ |
| 2 | +============================ |
3 | 3 |
|
4 |
| -Ocelot allows the user to change the HTTP request method that will be used when making a request to a downstream service. |
5 |
| - |
6 |
| -This achieved by setting the following Route configuration: |
| 4 | +Ocelot allows users to modify the HTTP request method used when making requests to a downstream service. |
| 5 | +This is achieved by setting the following route configuration: |
7 | 6 |
|
8 | 7 | .. code-block:: json
|
9 | 8 |
|
10 | 9 | {
|
11 |
| - "UpstreamPathTemplate": "/{url}", |
12 |
| - "DownstreamPathTemplate": "/{url}", |
13 |
| - "DownstreamScheme": "http", |
14 |
| - "DownstreamHostAndPorts": [ |
15 |
| - { "Host": "localhost", "Port": 54321 } |
16 |
| - ], |
17 |
| - "UpstreamHttpMethod": [ "Get" ], |
18 |
| - "DownstreamHttpMethod": "POST" // ! |
| 10 | + "UpstreamPathTemplate": "/{everything}", |
| 11 | + "DownstreamPathTemplate": "/{everything}", |
| 12 | + // other props and opts... |
| 13 | + "UpstreamHttpMethod": [ "Get" ], // we transform HTTP verb... |
| 14 | + "DownstreamHttpMethod": "Post" // ...from GET to POST |
19 | 15 | }
|
20 | 16 |
|
21 |
| -The key property here is **DownstreamHttpMethod** which is set as ``POST`` and the Route will only match on ``GET`` as set by **UpstreamHttpMethod**. |
| 17 | +The key property here is ``DownstreamHttpMethod``, which is set to ``POST``, and the route will only match ``GET``, as specified by ``UpstreamHttpMethod``. |
| 18 | + |
| 19 | +This feature is useful when interacting with downstream APIs that only support ``POST`` while presenting a RESTful interface. |
| 20 | + |
| 21 | +"""" |
22 | 22 |
|
23 |
| -This feature can be useful when interacting with downstream APIs that only support POST and you want to present some kind of RESTful interface. |
| 23 | +.. [#f1] This feature was released in version `14.0.8`_. |
| 24 | +.. _14.0.8: https://github.com/ThreeMammals/Ocelot/releases/tag/14.0.8 |
0 commit comments