Skip to content

Instantly share code, notes, and snippets.

@bill-evanson
Created September 29, 2015 12:15
Show Gist options
  • Select an option

  • Save bill-evanson/349004c1490025590dbd to your computer and use it in GitHub Desktop.

Select an option

Save bill-evanson/349004c1490025590dbd to your computer and use it in GitHub Desktop.
/**
* Like an internal redirect or an proxy. The URL in the browser doesn't
* change.
*/
public Promise<Result> forwardTo(String url) {
Promise<WS.Response> response = WS.url(url).get();
return response.map(new Function<WS.Response, Result>() {
public Result apply(WS.Response response) {
// Prevent browser from caching pages - this would be an
// security issue
response().setHeader("Cache-control", "no-cache, no-store");
return ok(response.getBody()).as("text/html");
}
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment