[libdancer-plugin-rest-perl] 11/63: support for resource definition in Dancer::Plugin::REST
Jonas Smedegaard
dr at jones.dk
Wed Jul 2 11:44:50 UTC 2014
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 5b8d80f7e7796eacc4642db8bc9a6abbce111840
Author: Alexis Sukrieh <sukria at sukria.net>
Date: Sat Apr 3 17:25:10 2010 +0200
support for resource definition in Dancer::Plugin::REST
---
lib/Dancer/Plugin/REST.pm | 29 ++++++++++++++++++++++++++---
1 file changed, 26 insertions(+), 3 deletions(-)
diff --git a/lib/Dancer/Plugin/REST.pm b/lib/Dancer/Plugin/REST.pm
index 1c2c08c..6d15da9 100644
--- a/lib/Dancer/Plugin/REST.pm
+++ b/lib/Dancer/Plugin/REST.pm
@@ -16,14 +16,37 @@ sub {
before sub {
my $format = params->{'format'};
- set serializer $serializers->{$format}
- if $format && $serializers->{$format};
+ return unless defined $format;
+
+ my $serializer = $serializers->{$format};
+ return unless defined $serializer;
+
+ set serializer => $serializer;
};
};
register resource =>
sub {
- die "TODO";
+ my ($resource, %triggers) = @_;
+
+ die "resource should be given with triggers"
+ unless defined $resource and
+ defined $triggers{get} and
+ defined $triggers{update} and
+ defined $triggers{delete} and
+ defined $triggers{create};
+
+ get "/${resource}/:id" => $triggers{get};
+ get "/${resource}/:id.:format" => $triggers{get};
+
+ put "/${resource}/:id" => $triggers{update};
+ put "/${resource}/:id.:format" => $triggers{update};
+
+ post "/${resource}" => $triggers{create};
+ post "/${resource}.:format" => $triggers{create};
+
+ del "/${resource}/:id" => $triggers{delete};
+ del "/${resource}/:id.:format" => $triggers{delete};
};
register_plugin;
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-perl/packages/libdancer-plugin-rest-perl.git
More information about the Pkg-perl-cvs-commits
mailing list