Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also compare across forks.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also compare across forks.
  • 4 commits
  • 10 files changed
  • 0 commit comments
  • 1 contributor
View
2  .gitignore
@@ -1,3 +1,5 @@
+Dancer-Plugin-REST*
+.build
pm_to_blib
t/logs
*.old
View
2  .mailmap
@@ -0,0 +1,2 @@
+Alexis Sukrieh <sukria@sukria.net> <alexis@weborama.com>
+Franck Cuny <franckc@cpan.org> <franck@lumberjaph.net>
View
42 CHANGES
@@ -1,42 +0,0 @@
-$NEXT
-
- [BUG FIXES]
- * 'prepare_serializer_for_format' was clobbering the
- default serializer. (RT#93478, reported by Pierre Vigier)
-
-0.07 2011-11-01
-
- * Minor updates to fix warnings with Dancer 1.3080
- * Fix POD
- (Alexis Sukrieh)
-
-0.06 2011-05-28
-
- [ TEST SUITE ]
- * Skip test t/03_resource.t if Dancer is not >= 1.3059_01
- A bug in Dancer::Test in previous versions prevent the test from passing.
-
-0.05 2011-03-04
-
- [ BUG FIXES ]
- * Fix the test suite with dancer_response
- * Fix dependencies: Dancer 1.3014
-
-Version 0.04
- [ Alexis Sukrieh ]
- * Add all HTTP response status
-
-Version 0.03
- [ Franck Cuny ]
- * New keywords for ReST response status
- (status_ok, status_created, ...)
-
-Version 0.02
- * 100% coverage
- * fix a bug in 'resource' (order of route hander definition)
-
-Version 0.0001_01
- * Support for prepare_serializer_for_format keyword
- autoamtically set a serializer according to params->{format}
- * Support for resource definition
- When a resource is defined a set of routes are defined in a RESTful manner.
View
40 Changes
@@ -0,0 +1,40 @@
+Revision history for {{$DIST}}
+
+{{$NEXT}}
+ [BUG FIXES]
+ - 'prepare_serializer_for_format' was clobbering the default serializer.
+ (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
+ - Fix POD (Alexis Sukrieh)
+
+0.06 2011-05-28
+ [TEST SUITE]
+ - Skip test t/03_resource.t if Dancer is not >= 1.3059_01 A bug in
+ Dancer::Test in previous versions prevent the test from passing.
+
+0.05 2011-03-04
+ [BUG FIXES]
+ - Fix the test suite with dancer_response
+ - Fix dependencies: Dancer 1.3014
+
+0.04 2010-12-22
+ - Add all HTTP response status (Alexis Sukrieh)
+
+0.03 2010-10-18
+ - New keywords for ReST response status (status_ok, status_created, ...)
+ (Franck Cuny)
+
+0.02 2010-10-14
+ - 100% coverage
+ - fix a bug in 'resource' (order of route hander definition)
+
+0.0001_01 2010-05-06
+ - Support for prepare_serializer_for_format keyword autoamtically set a
+ serializer according to params->{format}
+ - Support for resource definition When a resource is defined a set of
+ routes are defined in a RESTful manner.
+
View
20 MANIFEST
@@ -1,9 +1,21 @@
-CHANGES
-lib/Dancer/Plugin/REST.pm
-Makefile.PL
-MANIFEST This list of files
+Build.PL
+CONTRIBUTORS
+Changes
+INSTALL
+LICENSE
+MANIFEST
+META.json
+META.yml
README
+README.mkdn
+SIGNATURE
+lib/Dancer/Plugin/REST.pm
+t/00-compile.t
+t/000-report-versions-tiny.t
t/01_base.t
t/02_prepare_serializer_for_format.t
t/03_resource.t
+t/04_helpers.t
t/04_plugin_settings.t
+t/default-serializer.t
+xt/release/unused-vars.t
View
2  MANIFEST.SKIP
@@ -1,3 +1,4 @@
+dist\.ini
t\/logs\/.*log
cover_db
\.git
@@ -7,3 +8,4 @@ pm_to_blib
^Makefile$
MANIFEST.bak
MANIFEST.SKIP
+Dancer-Plugin-REST-.*
View
49 Makefile.PL
@@ -1,49 +0,0 @@
-use ExtUtils::MakeMaker;
-
-WriteMakefile1(
- NAME => 'Dancer::Plugin::REST',
- ABSTRACT => "REST plugin for Dancer",
- LICENSE => 'perl',
- VERSION_FROM => 'lib/Dancer/Plugin/REST.pm',
-
- META_MERGE => {
- resources => {
- repository => 'http://github.com/sukria/Dancer-Plugin-REST',
- },
- },
-
- BUILD_REQUIRES => {
- 'Test::More' => '0.87',
- },
-
- PREREQ_PM => {
- 'Dancer' => '1.3014',
- 'JSON' => 0,
- },
-
- test => {TESTS => join( ' ', (glob( 't/*.t'), glob('t/*/*.t')))},
-);
-
-sub WriteMakefile1 { #Written by Alexandr Ciornii, version 0.21. Added by eumm-upgrade.
- my %params=@_;
- my $eumm_version=$ExtUtils::MakeMaker::VERSION;
- $eumm_version=eval $eumm_version;
- die "EXTRA_META is deprecated" if exists $params{EXTRA_META};
- die "License not specified" if not exists $params{LICENSE};
- if ($params{BUILD_REQUIRES} and $eumm_version < 6.5503) {
- #EUMM 6.5502 has problems with BUILD_REQUIRES
- $params{PREREQ_PM}={ %{$params{PREREQ_PM} || {}} , %{$params{BUILD_REQUIRES}} };
- delete $params{BUILD_REQUIRES};
- }
- delete $params{CONFIGURE_REQUIRES} if $eumm_version < 6.52;
- delete $params{MIN_PERL_VERSION} if $eumm_version < 6.48;
- delete $params{META_MERGE} if $eumm_version < 6.46;
- delete $params{META_ADD} if $eumm_version < 6.46;
- delete $params{LICENSE} if $eumm_version < 6.31;
- delete $params{AUTHOR} if $] < 5.005;
- delete $params{ABSTRACT_FROM} if $] < 5.005;
- delete $params{BINARY_LOCATION} if $] < 5.005;
-
- WriteMakefile(%params);
-}
-
View
11 dist.ini
@@ -0,0 +1,11 @@
+name = Dancer-Plugin-REST
+author = Alexis Sukrieh <sukria@sukria.net>
+author = Franck Cuny <franckc@cpan.org>
+license = Perl_5
+copyright_holder = Alexis Sukrieh
+copyright_year = 2010
+
+[@Filter]
+-bundle = @YANICK
+-remove = Covenant
+authority=cpan:SUKRIA
View
24 lib/Dancer/Plugin/REST.pm
@@ -1,4 +1,6 @@
package Dancer::Plugin::REST;
+# ABSTRACT: A plugin for writing RESTful apps with Dancer
+
use strict;
use warnings;
@@ -6,9 +8,6 @@ use Carp 'croak';
use Dancer ':syntax';
use Dancer::Plugin;
-our $AUTHORITY = 'SUKRIA';
-our $VERSION = '0.07';
-
my $content_types = {
json => 'application/json',
yml => 'text/x-yaml',
@@ -30,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(
@@ -48,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;
}
};
@@ -177,10 +179,6 @@ __END__
=pod
-=head1 NAME
-
-Dancer::Plugin::REST - A plugin for writing RESTful apps with Dancer
-
=head1 SYNOPSYS
package MyWebService;
View
40 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/;
+}

No commit comments for this range

Something went wrong with that request. Please try again.