[libdancer-plugin-rest-perl] 03/05: order of route creation is important
Jonas Smedegaard
dr at jones.dk
Wed Jul 2 11:45:13 UTC 2014
This is an automated email from the git hooks/post-receive script.
js pushed a commit to annotated tag v0.11
in repository libdancer-plugin-rest-perl.
commit 6755186689b8f7c5dad8db479c0027974e354e8b
Author: Yanick Champoux <yanick at babyl.dyndns.org>
Date: Tue Mar 25 08:03:27 2014 -0400
order of route creation is important
Fixes #3
---
Changes | 2 ++
lib/Dancer/Plugin/REST.pm | 3 ++-
t/05_serializer_and_resource.t | 4 ++++
3 files changed, 8 insertions(+), 1 deletion(-)
diff --git a/Changes b/Changes
index 502a1ec..ba86d7c 100644
--- a/Changes
+++ b/Changes
@@ -4,6 +4,8 @@ Revision history for {{$DIST}}
[API CHANGES]
[BUG FIXES]
+ - Routes with ':id.:format' were not created properly.
+ (GH#3, reported by garu)
[DOCUMENTATION]
diff --git a/lib/Dancer/Plugin/REST.pm b/lib/Dancer/Plugin/REST.pm
index bdcc606..17dc899 100644
--- a/lib/Dancer/Plugin/REST.pm
+++ b/lib/Dancer/Plugin/REST.pm
@@ -77,9 +77,10 @@ register resource => sub {
if ( $t eq 'create' ) {
$method->( "/${resource}" => $triggers{$t} );
+ $method->( "/${resource}.:format" => $triggers{$t} );
}
else {
- for my $ext ( '', '.:format' ) {
+ for my $ext ( '.:format', '' ) {
$method->( "/${resource}/:id$ext" => $triggers{$t} );
}
}
diff --git a/t/05_serializer_and_resource.t b/t/05_serializer_and_resource.t
index fdfee4a..d0b89fd 100644
--- a/t/05_serializer_and_resource.t
+++ b/t/05_serializer_and_resource.t
@@ -10,6 +10,9 @@ $dancer_version =~ s/_//g;
plan skip_all => "Dancer 1.3059_01 is needed for this test (you have $dancer_version)"
if $dancer_version < 1.305901;
+plan skip_all => 'tests require JSON'
+ unless Dancer::ModuleLoader->load('JSON');
+
{
package Webservice;
use Dancer;
@@ -17,6 +20,7 @@ plan skip_all => "Dancer 1.3059_01 is needed for this test (you have $dancer_ver
setting environment => 'testing';
prepare_serializer_for_format;
+
resource user =>
get => sub { [ id => params->{id}, format => params->{format} ] },
delete => sub { [ id => params->{id}, format => params->{format} ] },
--
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