Problem
I want the URL segment here/is/a/request/to/letsay/a/user turn into one orginalRequest parameter in Play! route
Why
To solve the same origin policy using JSON and AJAX, we decided to create a web services client on our own server that redirects all JSON calls to the external REST API.
Is there a way in the game! A raster route file that I can threaten to ever appear after / api / as one single parameter?
In the route:
GET /api/fromhere/is/what/iwant/as/single/parameter App.getFromOtherDomain
In the application:
public void getFromOtherDomain(String orginalRequest){ WSRequest req = WS.url("https://api.otherdomain.com/" + orginalRequest); Promise<HttpResponse> respAsync = req.getAsync(); HttpResponse resp = await(respAsync); renderJSON(resp.getJson()); }
user920041
source share