-- Garrett Goebel <[EMAIL PROTECTED]> wrote: > I'm sure this is too late to be useful. But here is > my subclassed > Catalyst::Action to implemented RESTful request > method based > dispatching. [I've been working on this in my free > time. Which I have > precious little of lately. My apologies.] > > The references to $c->request->path_parameters are > to support RoR > style processing of urls (foo.com/person;create) > where > Catalyst::Dispatcher->perpare_action is overridden > to match url paths > separate from path parameters and file extensions. > > I also override Catalyst::Dispatcher->setup_actions > to change the > default method_action_class to my subclass of > Catalyst::Action. I was > surprised that default method_action_class and > action_container_class > appear to be hard coded... > [snipped content]
You can do this more easily as a Action Class, (see http://search.cpan.org/~mramberg/Catalyst-Runtime-5.7003/lib/Catalyst/Manual/Actions.pod for some documentation). This was released with Catalyst 5.7x and easy to miss if you don't have time to watch the mailing list closely. I wrote something similar and shared it with the list but there didn't seem to be much interest. I've attached what I did for you to check out. Maybe if this kind of this is useful to you we can work together to fix it up and write some tests and release it as a real module. Let me know if you have time for that. I kind of wanted this to be more than just an action to match on the method type, I was hoping to have it automatically in/deflate the request body to something like XML::Simple or other XML object to make it easier to build true RESTful apps. If would be cool if (something like) sub restful_xml : Local ActionClass('Rest') Methods('GET','POST') BodyAs('XML::Simple') { my ($self, $c) = @_; my $xml = $c->xml; ## XML::Simple inflated from ## $c->request->body $c->xml->{entry} = "blah blah blah" } And then the return would serialize the xml object. I'm not sure about the syntax here (Am particularly doubtful about '$c->xml' since I don't think it's nice to polute the context namespace this way) but something like this could be useful. Let me know what you think I have some time to clean this up. --john __________________________________________________ Do You Yahoo!? Tired of spam? Yahoo! Mail has the best spam protection around http://mail.yahoo.com
Rest.pm
Description: 3911937034-Rest.pm
_______________________________________________ List: [email protected] Listinfo: http://lists.rawmode.org/mailman/listinfo/catalyst Searchable archive: http://www.mail-archive.com/[email protected]/ Dev site: http://dev.catalyst.perl.org/
