You don't need 'create' & 'update' & 'delete' parts of your URL - those should be denoted by the request type - POST, PUT, or DELETE right? Similarly you don't need 'id' in the url - so POST to /api/rest/cd will create a cd. A PUT to /api/rest/cd/5 will update that CD - a DELETE to /api/rest/cd/5 will delete that CD...

Zbigniew Lukasiak wrote:
Hi there,

This is a frequently recurring conversation - so I created a wiki page
to gather all the points where we reached some consensus:  For the start I just dumped my
opinions.  I tried to be not controversial - but it is a wiki - if you
don't agree then you can edit it and make it more acceptable for you.

I am especially waiting for people with opinions on the REST and
browser REST part - I have got much knowledge in that area.


On Sun, May 4, 2008 at 2:38 AM, luke saunders <[EMAIL PROTECTED]> wrote:
I have started to write a Catalyst base controller for REST style CRUD
via DBIC. I have noticed that a number of other people have been
working on or are thinking about working on something similar, most
notabley J. Shirley who seems to be creating
and some chaps from a recent thread on this list (entitled
"Dispatching with Chained vs HTTP method").

Ideally I would like to merge J. Shirley's effort into mine (or visa
versa) along with anything that anyone else has. Basically I want to
avoid ending up with a load of modules that all do the same thing.

My effort is heavily based on something mst wrote a while ago, and
since then I've ended up writing something very similar for every
project I've worked on which indicates it's worth OSing. Essentially
it is used like so:

 package MyApp::Controller::API::REST::CD;

 use base qw/Catalyst::Controller::REST::DBIC/;


   ( action => { setup => { PathPart => 'cd', Chained =>
'/api/rest/rest_base' } },
     class => 'RestTestDB::CD',
     create_requires => ['artist', 'title', 'year' ],
     update_allows => ['title', 'year']

And this gets you the following endpoints to fire requests at:

The full source is here:

If you have a few moments please have a look, especially if you are
working on something similar. Today I even wrote a test suite which
has a test app and is probably the best place to look to see what it

Note that it lacks:
- list and view type methods which dump objects to JSON (or whatever)
- clever validation - it should validate based on the DBIC column
definitions but it doesn't
- any auth - not sure if it should or not, but it's possible

Also it doesn't distinguish between POST, PUT, DELETE and GET HTTP
requests favouring instead entirely separate endpoints, but that's up
for discussion.

So, J. Shirley, do you have any interest in a merge? And others, do
you have ideas and would you like to contribute?


Searchable archive:
Dev site:

Searchable archive:
Dev site:

Reply via email to