This is an automated email from the git hooks/post-receive script. js pushed a commit to annotated tag 0.07 in repository libdancer-plugin-rest-perl.
commit a05d52d9e057dfd11704e5ff4a5c320adebe76a7 Author: franck cuny <fra...@lumberjaph.net> Date: Sat Apr 3 18:41:47 2010 +0200 load serializers list from config is available --- lib/Dancer/Plugin/REST.pm | 32 +++++++++++++++++++------------- 1 file changed, 19 insertions(+), 13 deletions(-) diff --git a/lib/Dancer/Plugin/REST.pm b/lib/Dancer/Plugin/REST.pm index 6d15da9..5b1b7df 100644 --- a/lib/Dancer/Plugin/REST.pm +++ b/lib/Dancer/Plugin/REST.pm @@ -1,18 +1,24 @@ package Dancer::Plugin::REST; use Dancer ':syntax'; use Dancer::Plugin; +use Dancer::Config qw/plugin_setting/; our $AUTHORITY = 'SUKRIA'; our $VERSION = '0.1'; register prepare_serializer_for_format => sub { - my $serializers = { - 'json' => 'JSON', - 'yml' => 'YAML', - 'xml' => 'XML', - 'dump' => 'Dumper', - }; + my $conf = plugin_setting; + my $serializers = ( + ( $conf && exists $conf->{serializers} ) + ? $conf->{serializers} + : { + 'json' => 'JSON', + 'yml' => 'YAML', + 'xml' => 'XML', + 'dump' => 'Dumper', + } + ); before sub { my $format = params->{'format'}; @@ -30,10 +36,10 @@ sub { my ($resource, %triggers) = @_; die "resource should be given with triggers" - unless defined $resource and + unless defined $resource and defined $triggers{get} and - defined $triggers{update} and - defined $triggers{delete} and + defined $triggers{update} and + defined $triggers{delete} and defined $triggers{create}; get "/${resource}/:id" => $triggers{get}; @@ -68,13 +74,13 @@ Dancer::Plugin::REST - A plugin for writing RESTful apps with Dancer prepare_serializer_for_format; - get '/user/:id.:format' => sub { - User->find(params->{id}); + get '/user/:id.:format' => sub { + User->find(params->{id}); }; # curl http://mywebservice/user/42.json { "id": 42, "name": "John Foo", email: "jhon....@example.com"} - + # curl http://mywebservice/user/42.yml -- id: 42 @@ -102,7 +108,7 @@ handlers, without taking care of the outgoing data format. This keyword lets you declare a resource your application will handle. - resource user => + resource user => get => sub { # return user where id = params->{id} }, create => sub { # create a new user with params->{user} }, delete => sub { # delete user where id = params->{id} }, -- Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-perl/packages/libdancer-plugin-rest-perl.git _______________________________________________ Pkg-perl-cvs-commits mailing list Pkg-perl-cvs-commits@lists.alioth.debian.org http://lists.alioth.debian.org/cgi-bin/mailman/listinfo/pkg-perl-cvs-commits