Re: resRouteURLForActionNamed?
Re: resRouteURLForActionNamed?
- Subject: Re: resRouteURLForActionNamed?
- From: Paul D Yu <email@hidden>
- Date: Fri, 29 Apr 2011 14:36:32 -0400
ERRest FTW!!!
On Apr 29, 2011, at 2:35 PM, Pascal Robert wrote:
> ERXRouteLink and ERXRouteUrlUtils are doing the job quite well.
>
>> Just saw that (and ERXRouteURL). Will take a look at those.
>>
>>> probably not exactly what you want, but there's ERXRouteUrlUtils ... it's making a bunch of assumptions about the route syntax, though.
>>>
>>> On Apr 29, 2011, at 10:39 AM, Pascal Robert wrote:
>>>
>>>>
>>>> Le 2011-04-29 à 09:35, Mike Schrag a écrit :
>>>>
>>>>> you would have to replace them yourself, but it's sort of unclear what you would replace them WITH ... they're not valid urls without having an actual value in those slots.
>>>>
>>>> Yes, I do know that for "show" pages, I will have to add the IDs myself. That's not only for the manifest, I'm also playing with the automatic HTML routing to make the WOWODC mini app (to view the schedule + the presenters) so I need to generate the URLs to go from the "index" page (list of presentations) to the session detail page. If we had a "restRouteUrl" method, I would just need to add the ID of the conference session object to the URL returned by "restRouteUrl".
>>>>
>>>>> On Apr 29, 2011, at 9:30 AM, Pascal Robert wrote:
>>>>>
>>>>>>
>>>>>> 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@hidden
>>>>>>
>>>>>> 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@hidden)
>>>>>> Help/Unsubscribe/Update your Subscription:
>>>>>>
>>>>>> This email sent to email@hidden
>>>>>
>>>>
>>>
>>
>> _______________________________________________
>> Do not post admin requests to the list. They will be ignored.
>> Webobjects-dev mailing list (email@hidden)
>> Help/Unsubscribe/Update your Subscription:
>>
>> This email sent to email@hidden
>
> _______________________________________________
> Do not post admin requests to the list. They will be ignored.
> Webobjects-dev mailing list (email@hidden)
> Help/Unsubscribe/Update your Subscription:
>
> This email sent to email@hidden
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Webobjects-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden