<br><br><div class="gmail_quote">On Tue, Apr 26, 2011 at 11:37 AM, Kyle Hall <span dir="ltr">&lt;<a href="mailto:kyle.m.hall@gmail.com">kyle.m.hall@gmail.com</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">

Hello all,<br>
  I&#39;m trying to write a REST service using the REST controller. The<br>
problem I&#39;m running into is I can&#39;t seem to use &#39;index&#39; as I can with<br>
the standard catalyst controller. I would like my URIs to look like<br>
/api/rest/documents, /api/rest/staff and so on. From these paths I<br>
would like to do the standard GET, PUT, POST and DELETE calls.<br>
<br>
However, if I create the controller<br>
MyApp::Controller::API::REST::Documents, and I try this:<br>
   sub index : Local : ActionClass(&#39;REST&#39;) {}<br>
The system loads this as the path action /api/rest/documents/index.<br>
<br>
Any idea what I&#39;m doing wrong?<br>
<br>
Thanks,<br>
Kyle<br>
<br>
<a href="http://www.kylehall.info" target="_blank">http://www.kylehall.info</a><br>
Mill Run Technology Solutions ( <a href="http://millruntech.com" target="_blank">http://millruntech.com</a> )<br>
Crawford County Federated Library System ( <a href="http://www.ccfls.org" target="_blank">http://www.ccfls.org</a> )<br>
Meadville Public Library ( <a href="http://www.meadvillelibrary.org" target="_blank">http://www.meadvillelibrary.org</a> )<br>
<br>
_______________________________________________<br>
List: <a href="mailto:Catalyst@lists.scsys.co.uk">Catalyst@lists.scsys.co.uk</a><br>
Listinfo: <a href="http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst" target="_blank">http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst</a><br>
Searchable archive: <a href="http://www.mail-archive.com/catalyst@lists.scsys.co.uk/" target="_blank">http://www.mail-archive.com/catalyst@lists.scsys.co.uk/</a><br>
Dev site: <a href="http://dev.catalyst.perl.org/" target="_blank">http://dev.catalyst.perl.org/</a><br>
</blockquote></div><br>Have you considered using Chained for this?  Your URL structure looks like it would lend itself nicely to that.<div><br></div><div>You&#39;d do something like:</div><div><br></div><div>package <meta charset="utf-8">MyApp::Web::Controller::API::REST::Documents;</div>

<div>use ...</div><div>BEGIN { extends &#39;MyApp::Web::Controller::API::REST&#39; }</div><div><br></div><meta charset="utf-8"><div># chaining to &#39;.&#39; allows you to have a chain root in a parent class</div><div># that you can chain off of and inherit functionality from (see <a href="http://search.cpan.org/~bobtfish/Catalyst-Runtime-5.80032/lib/Catalyst/DispatchType/Chained.pm#Attributes">http://search.cpan.org/~bobtfish/Catalyst-Runtime-5.80032/lib/Catalyst/DispatchType/Chained.pm#Attributes</a> under &quot;Chained&quot;)</div>

<div># also, specify the path part here, so index acts how you want it to as an end point.</div><div>sub documents : Chained(&#39;.&#39;) PathPart(&#39;documents&#39;) CaptureArgs(0) {</div><div>  my ($self, $c) = @_;</div>

<div>  # do whatever document grabbing functionality you need to do here</div><div>}</div><div><br></div><div>sub index : Chained(&#39;documents&#39;) PathPart(&#39;&#39;) Args(0) {</div><div>  my ($self, $c) = @_;</div>
<div>
  # display stuff etc</div><div>}</div><div><br></div><div>NOTE: This is untested code, but it SHOULD give you an idea of what to do.</div><div> <br>-- <br>Devin Austin<br><a href="http://www.codedright.net">http://www.codedright.net</a><br>

9702906669 - Cell<br>
</div>