get '/service/items' => sub {
content_type 'application/json' ;
my $items = $dbh->selectall_arrayref(...) ;
return to_json($items) ;
} ;
post '/service/items/:item_id' => sub {
content_type 'application/json' ;
$dbh->do(...) ;
return to_json({updated => 1}) ;
} ;
put '/service/items' => sub {
content_type 'application/json' ;
$dbh->do(...) ;
return to_json({added => 1}) ;
} ;
del '/service/items/:item_id' => sub {
content_type 'application/json' ;
$dbh->do(...) ;
return to_json({deleted => 1}) ;
} ;
|