POST
requests from clients to upstream services that support only PUT
and DELETE
operations, providing a modern interface to your users. It is a simple middleware that changes only the method and not the payload or headers. You can, however, combine this with the Request Header Transform and Request Body Tranform to apply more complex transformation to requests.
PUT
or DELETE
) for different functionality but you want to wrap this in a single client-facing API, you can provide a simple interface offering a single method (e.g. POST
) and then use the method transform middleware to map requests to correct upstream method.
transformRequestMethod
) can be added to the operations
section of the Tyk OAS Extension (x-tyk-api-gateway
) in your Tyk OAS API Definition for the appropriate operationId
(as configured in the paths
section of your OpenAPI Document). Endpoint paths
entries (and the associated operationId
) can contain wildcards in the form of any string bracketed by curly braces, for example /status/{code}
. These wildcards are so they are human readable and do not translate to variable names. Under the hood, a wildcard translates to the “match everything” regex of: (.*)
.
You only need to enable the middleware (set enabled:true
) and then configure toMethod
as the new HTTP method to which the request should be transformed. The design of the Tyk OAS API Definition takes advantage of the operationId
defined in the OpenAPI Document that declares both the path and method for which the method should be transformed.
All standard HTTP methods are supported: GET
, PUT
, POST
, PATCH
, DELETE
, HEAD
, OPTIONS
.
For example:
GET /status/200
endpoint. Any request received to that endpoint will be modified to POST /status/200
.
The configuration above is a complete and valid Tyk OAS API Definition that you can import into Tyk to try out the request method transform.
method_transforms
object to the extended_paths
section of your API definition.
It has the following configuration:
path
: the endpoint pathmethod
: the endpoint HTTP methodto_method
: The new HTTP method to which the request should be transformedGET
, PUT
, POST
, PATCH
, DELETE
, HEAD
, OPTIONS
.
For example:
GET
requests to the /status/200
endpoint. Any request received to that endpoint will be modified to POST /status/200
.
method_transforms
object to the extended_paths
section of your API definition:
/transform
and forwards requests upstream to http://httpbin.org.
In this example the Request Method Transform middleware has been configured for HTTP GET
requests to the /anything
endpoint. Any request received to that endpoint will be modified to POST /anything
.