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)?
I was able to do part of it like this:
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).
--
Pascal Robert
[email protected]
WOWODC 2011 : July 1-2-3, Montreal. wowodc.com
AIM/iChat : MacTICanada
LinkedIn : http://www.linkedin.com/in/macti
Twitter : pascal_robert
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Webobjects-dev mailing list ([email protected])
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/webobjects-dev/archive%40mail-archive.com
This email sent to [email protected]