This is an automated email from the git hooks/post-receive script. js pushed a commit to annotated tag v0.08 in repository libdancer-plugin-rest-perl.
commit 8ef59f590955cc8529e0023edab8fc328d4f705c Author: Yanick Champoux <yan...@babyl.dyndns.org> Date: Mon Mar 10 20:59:09 2014 -0400 serializer wasn't detected in time for deserialization --- Changes | 4 +++- lib/Dancer/Plugin/REST.pm | 15 +++++++++------ t/two-posts.t | 40 ++++++++++++++++++++++++++++++++++++++++ 3 files changed, 52 insertions(+), 7 deletions(-) diff --git a/Changes b/Changes index b5e1aac..eeb3dfe 100644 --- a/Changes +++ b/Changes @@ -3,7 +3,9 @@ Revision history for {{$DIST}} {{$NEXT}} [BUG FIXES] - 'prepare_serializer_for_format' was clobbering the default serializer. - (RT#93478, reported by Pierre Vigier) + (RT#93478, reported by Pierre Vigier, fix by Yanick Champoux) + - serializer not detected in time for first deserialization. + (RT#78437, reported by Andrew Solomon, fix by Yanick Champoux) 0.07 2011-11-01 - Minor updates to fix warnings with Dancer 1.3080 diff --git a/lib/Dancer/Plugin/REST.pm b/lib/Dancer/Plugin/REST.pm index 1cd5757..855c770 100644 --- a/lib/Dancer/Plugin/REST.pm +++ b/lib/Dancer/Plugin/REST.pm @@ -29,12 +29,10 @@ register prepare_serializer_for_format => sub { ); hook 'before' => sub { - - my $format = params->{'format'} - or return; - # remember what was there before - $default_serializer = setting 'serializer'; + $default_serializer ||= setting 'serializer'; + + my $format = params->{'format'} or return; my $serializer = $serializers->{$format} or return halt( @@ -47,12 +45,17 @@ register prepare_serializer_for_format => sub { set serializer => $serializer; + # check if we were supposed to deserialize the request + Dancer::Serializer->process_request( + Dancer::SharedData->request + ); + content_type $content_types->{$format} || setting('content_type'); }; hook after => sub { # put it back the way it was - set serializer => $default_serializer if $default_serializer; + set serializer => $default_serializer; } }; diff --git a/t/two-posts.t b/t/two-posts.t new file mode 100644 index 0000000..cbac5dc --- /dev/null +++ b/t/two-posts.t @@ -0,0 +1,40 @@ +use strict; +use warnings; + +{ + package Foo; + + use Dancer; + use Dancer::Plugin::REST; + + prepare_serializer_for_format; + + post '/foo.:format' => sub { + return params; + }; + +} + +use Test::More; +use Dancer::ModuleLoader; + +plan skip_all => 'tests require JSON' + unless Dancer::ModuleLoader->load('JSON'); + +plan tests => 2; + +use Dancer::Test; +use HTTP::Headers; + +my $head = HTTP::Headers->new; + +$head->header("content-type" => "application/json"); + +for ( 1..2 ) { + my $resp = dancer_response( 'POST' => '/foo.json', { + body => '{"yin":"yang","foo":"bar"}', + headers => $head, + }); + + like $resp->content, qr/yin/; +} -- 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