Archive for October, 2012

CRUD webapplication with Mojolicious.

October 6, 2012

As a ‘sunday’ programmer I like perl. I read about Mojolicious and I like the concept a lot. Most examples are not heavy on the typical CRUD use. So I will try and make a sample project of a CRUD application, listing records, searching, editing, creating and deleting. 

The first thing to do is to design the routing. The routing I came up with is like this:

$r->get(‘/crud/:controller/new’)->to(action => ‘new’);
$r->post(‘/crud/:controller’)->to(action => ‘new’);

$r->get(‘/crud/:controller/view1/:id’)->to(action => ‘view1’);

$r->get(‘/crud/:controller/edit/:id’)->to(action => ‘editform1’);
$r->put(‘/crud/:controller/edit/:id’)->to(action => ‘editform1’);

$r->get(‘/crud/:controller/delete/:id’)->to(action =>’delete_confirm’);
$r->delete(‘/crud/:controller/delete:id’)->to(action => ‘delete1’);

$r->get(‘/crud/:controller’)->to(action => ‘list’);
$r->get(‘/crud/:controller/search’)->to(action => ‘search’);
$r->get(‘/crud/:controller/search/:term’)->to(action => ‘search’); #DEBUG
$r->put(‘/crud/:controller/search/:term’)->to(action => ‘search’);

I want to make it REST-ful , see how that works.

 

 

Advertisements