in reply to RESTful web-services in Perl

Dancer works extremely well for implementing RESTful services.

Replies are listed 'Best First'.
Re^2: RESTful web-services in Perl
by onelesd (Pilgrim) on Sep 22, 2011 at 21:23 UTC

    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}) ; } ;