just looking for some advice on the best way to do something.. So I wrote a controller class using Chained that basically auto-converts any DBIx::Schema (which includes a tiny extra base class itself) into a REST API.. Well, a simple one anyway - it supports find and search so far, and foreign keys in the objects get serialised into hashes of the URIs to fetch them.
All working nicely so far, but this is all for GET queries. But the behaviour should be different depending upon whether you GET /item/1234 or DELETE /item/1234 etc. I was thinking something like this: (Abbreviated code below) ------------ sub item_by_id : Chained CaptureArgs(2) { my ($self, $c, $type, $id) = @_; $c->stash->{item} = $c->model("DB:$type")->find($id); } sub delete : Chained('item_by_id') Args ActionClass('MethodDELETE') { my ($self, $c) = @_; $c->stash->{item}->delete; } sub modify : Chained('item_by_id') Args ActionClass('MethodPUT') { my ($self, $c) = @_; $c->stash->{item}->update($c->request->params); } ------------ Then the appropriate ActionClasses would check if the $c->req->method eq 'GET' or 'DELETE' or whatever. But I was just wondering if you had other ideas, and if using ActionClasses with Chained actions is crackfuelled and going to lead to a world of misery and pain. Cheers! Toby _______________________________________________ List: Catalyst@lists.scsys.co.uk Listinfo: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst Searchable archive: http://www.mail-archive.com/catalyst@lists.scsys.co.uk/ Dev site: http://dev.catalyst.perl.org/