Le 2011-04-28 à 20:23, Pascal Robert a écrit :
Yes, I know that method doesn't exist, but I'm looking for something that would generate the URL (without the host) for the routes. The reason? I want to add them to a HTML5 cache manifest so if I could dynamically generate the list of URLs, that would be cool! I didn't see anything obvious for this in ERXRoute or ERXRouteRequestHandler.
So, how can I find those URLs a la directActionURLForActionNamed but for REST routes (especially the ones using HTTP GET)?
public WOActionResults manifestAction() {
WOResponse response = new WOResponse();
StringBuffer content = new StringBuffer();
content.append("CACHE MANIFEST\n");
content.append("CACHE:\n");
String baseUrl = this.context()._urlWithRequestHandlerKey(ERXRouteRequestHandler.Key, null, null, false);
content.append(baseUrl + "/sessions.html" + "\n");
response.setContent(content.toString());
response.setHeader("text/cache-manifest", "Content-Type");
return response;
}
That work, but I still have to add the last part of the URL. I tried with:
for (ERXRoute route: Application.restRequestHandler().routes()) {
if (Method.Get.equals(route.method())) {
content.append(baseUrl + route.routePattern().toString + "\n");
}
}
But I didn't find a way remove the regex constructs (I guess I would use string.replace to remove them).