Example REST in Dancer:
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}) ; } ;
In reply to Re^2: RESTful web-services in Perl
by onelesd
in thread RESTful web-services in Perl
by morgon
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |