As part of my API proxy, I'd like to map a target resource called search to the proxy resource super-search. So if my base url is myproxy/v1.2, and I create the resource super-search, then I'd like the URLs to be modified as below
myproxy/v1.2/super-search&apikey=123
to
myproxy/v1.2/search&apikey=123
It seems, from reading the documentation here, and this question, that the way to do this would be to simply modify the URL with a JavaScript call out in the pre-flow of the target endpoint by doing
context.targetRequest.url.replace('/super-search', '/search')
Unfortunately though, the URL doesn't seem to include the resource name, so there's nothing to replace.
Alternatively I can do
context.setVariable('target.copy.pathsuffix', false);
context.targetRequest.url += '/search';
but this seems to drop all my query parameters!
How can I change only the resource name on the target without affecting the other elements of the request?