We are trying to write some middleware to essentially hijack certain request (based on host/path/querystring) and forward to a different endpoint. Then rewrite the response based on a set of regular expressions to the user.
We have it able to match on path and querystring. It seems that
Host is not exposed in the
Request object. (point 1)
Some of the endpoints will have a querystring that need to be preserved. As far as what we could find (and read)
TykMakeRequest does not support parameters. (point 2, but I can work around that w/
The full (mangled)
Response from the endpoint , but the middleware's
request.ReturnOverrides does not support that. It only seems to support the message as an error string inside as json and the inablity to set headers.
TykJsResponse does support headers and can return a full response, but is not available in middleware. (point 3, but the one that matters the most)
We've had some success setting up the script as a
Virtual Path. Unfortunately, we would like to reuse it across a few different APIs and we cannot get past the Host/Query String matches in that Endpoint designer.
We're looking for some idea around this.
(Ultimately, we would love love love to see something in the Endpoint Designer
- fullstring = $0
- proto = $1
- domain = $2
- path = $3
- responseAs = http$proto://$domain/abc/$path
- endpoint = https://backend.otherdomain.com/getWsdl?$path
response transform substitute:
- https://backend.otherdomain.com/getWsdl?$path to $responseAs