Dancer-Plugin-REST-0.12000755001750001750 015135450223 14556 5ustar00yanickyanick000000000000README100644001750001750 13615135450223 15477 0ustar00yanickyanick000000000000Dancer-Plugin-REST-0.12Dancer::Plugin::REST A Dancer plugin to transform your Dancer app in a RESTful webservice. INSTALL100644001750001750 463115135450223 15674 0ustar00yanickyanick000000000000Dancer-Plugin-REST-0.12This is the Perl distribution Dancer-Plugin-REST. Installing Dancer-Plugin-REST is straightforward. ## Installation with cpanm If you have cpanm, you only need one line: % cpanm Dancer::Plugin::REST If it does not have permission to install modules to the current perl, cpanm will automatically set up and install to a local::lib in your home directory. See the local::lib documentation (https://metacpan.org/pod/local::lib) for details on enabling it in your environment. ## Installing with the CPAN shell Alternatively, if your CPAN shell is set up, you should just be able to do: % cpan Dancer::Plugin::REST ## Manual installation As a last resort, you can manually install it. If you have not already downloaded the release tarball, you can find the download link on the module's MetaCPAN page: https://metacpan.org/pod/Dancer::Plugin::REST Untar the tarball, install configure prerequisites (see below), then build it: % perl Makefile.PL % make && make test Then install it: % make install On Windows platforms, you should use `dmake` or `nmake`, instead of `make`. If your perl is system-managed, you can create a local::lib in your home directory to install modules to. For details, see the local::lib documentation: https://metacpan.org/pod/local::lib The prerequisites of this distribution will also have to be installed manually. The prerequisites are listed in one of the files: `MYMETA.yml` or `MYMETA.json` generated by running the manual build process described above. ## Configure Prerequisites This distribution requires other modules to be installed before this distribution's installer can be run. They can be found under the "configure_requires" key of META.yml or the "{prereqs}{configure}{requires}" key of META.json. ## Other Prerequisites This distribution may require additional modules to be installed after running Makefile.PL. Look for prerequisites in the following phases: * to run make, PHASE = build * to use the module code itself, PHASE = runtime * to run tests, PHASE = test They can all be found in the "PHASE_requires" key of MYMETA.yml or the "{prereqs}{PHASE}{requires}" key of MYMETA.json. ## Documentation Dancer-Plugin-REST documentation is available as POD. You can run `perldoc` from a shell to read the documentation: % perldoc Dancer::Plugin::REST For more information on installing Perl modules via CPAN, please see: https://www.cpan.org/modules/INSTALL.html LICENSE100644001750001750 4643515135450223 15700 0ustar00yanickyanick000000000000Dancer-Plugin-REST-0.12This software is copyright (c) 2026 by Alexis Sukrieh. This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself. Terms of the Perl programming language system itself a) the GNU General Public License as published by the Free Software Foundation; either version 1, or (at your option) any later version, or b) the "Artistic License" --- The GNU General Public License, Version 1, February 1989 --- This software is Copyright (c) 2026 by Alexis Sukrieh. This is free software, licensed under: The GNU General Public License, Version 1, February 1989 GNU GENERAL PUBLIC LICENSE Version 1, February 1989 Copyright (C) 1989 Free Software Foundation, Inc. 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed. Preamble The license agreements of most software companies try to keep users at the mercy of those companies. By contrast, our General Public License is intended to guarantee your freedom to share and change free software--to make sure the software is free for all its users. The General Public License applies to the Free Software Foundation's software and to any other program whose authors commit to using it. You can use it for your programs, too. When we speak of free software, we are referring to freedom, not price. Specifically, the General Public License is designed to make sure that you have the freedom to give away or sell copies of free software, that you receive source code or can get it if you want it, that you can change the software or use pieces of it in new free programs; and that you know you can do these things. To protect your rights, we need to make restrictions that forbid anyone to deny you these rights or to ask you to surrender the rights. These restrictions translate to certain responsibilities for you if you distribute copies of the software, or if you modify it. For example, if you distribute copies of a such a program, whether gratis or for a fee, you must give the recipients all the rights that you have. You must make sure that they, too, receive or can get the source code. And you must tell them their rights. We protect your rights with two steps: (1) copyright the software, and (2) offer you this license which gives you legal permission to copy, distribute and/or modify the software. Also, for each author's protection and ours, we want to make certain that everyone understands that there is no warranty for this free software. If the software is modified by someone else and passed on, we want its recipients to know that what they have is not the original, so that any problems introduced by others will not reflect on the original authors' reputations. The precise terms and conditions for copying, distribution and modification follow. GNU GENERAL PUBLIC LICENSE TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION 0. This License Agreement applies to any program or other work which contains a notice placed by the copyright holder saying it may be distributed under the terms of this General Public License. The "Program", below, refers to any such program or work, and a "work based on the Program" means either the Program or any work containing the Program or a portion of it, either verbatim or with modifications. Each licensee is addressed as "you". 1. You may copy and distribute verbatim copies of the Program's source code as you receive it, in any medium, provided that you conspicuously and appropriately publish on each copy an appropriate copyright notice and disclaimer of warranty; keep intact all the notices that refer to this General Public License and to the absence of any warranty; and give any other recipients of the Program a copy of this General Public License along with the Program. You may charge a fee for the physical act of transferring a copy. 2. You may modify your copy or copies of the Program or any portion of it, and copy and distribute such modifications under the terms of Paragraph 1 above, provided that you also do the following: a) cause the modified files to carry prominent notices stating that you changed the files and the date of any change; and b) cause the whole of any work that you distribute or publish, that in whole or in part contains the Program or any part thereof, either with or without modifications, to be licensed at no charge to all third parties under the terms of this General Public License (except that you may choose to grant warranty protection to some or all third parties, at your option). c) If the modified program normally reads commands interactively when run, you must cause it, when started running for such interactive use in the simplest and most usual way, to print or display an announcement including an appropriate copyright notice and a notice that there is no warranty (or else, saying that you provide a warranty) and that users may redistribute the program under these conditions, and telling the user how to view a copy of this General Public License. d) You may charge a fee for the physical act of transferring a copy, and you may at your option offer warranty protection in exchange for a fee. Mere aggregation of another independent work with the Program (or its derivative) on a volume of a storage or distribution medium does not bring the other work under the scope of these terms. 3. You may copy and distribute the Program (or a portion or derivative of it, under Paragraph 2) in object code or executable form under the terms of Paragraphs 1 and 2 above provided that you also do one of the following: a) accompany it with the complete corresponding machine-readable source code, which must be distributed under the terms of Paragraphs 1 and 2 above; or, b) accompany it with a written offer, valid for at least three years, to give any third party free (except for a nominal charge for the cost of distribution) a complete machine-readable copy of the corresponding source code, to be distributed under the terms of Paragraphs 1 and 2 above; or, c) accompany it with the information you received as to where the corresponding source code may be obtained. (This alternative is allowed only for noncommercial distribution and only if you received the program in object code or executable form alone.) Source code for a work means the preferred form of the work for making modifications to it. For an executable file, complete source code means all the source code for all modules it contains; but, as a special exception, it need not include source code for modules which are standard libraries that accompany the operating system on which the executable file runs, or for standard header files or definitions files that accompany that operating system. 4. You may not copy, modify, sublicense, distribute or transfer the Program except as expressly provided under this General Public License. Any attempt otherwise to copy, modify, sublicense, distribute or transfer the Program is void, and will automatically terminate your rights to use the Program under this License. However, parties who have received copies, or rights to use copies, from you under this General Public License will not have their licenses terminated so long as such parties remain in full compliance. 5. By copying, distributing or modifying the Program (or any work based on the Program) you indicate your acceptance of this license to do so, and all its terms and conditions. 6. Each time you redistribute the Program (or any work based on the Program), the recipient automatically receives a license from the original licensor to copy, distribute or modify the Program subject to these terms and conditions. You may not impose any further restrictions on the recipients' exercise of the rights granted herein. 7. The Free Software Foundation may publish revised and/or new versions of the General Public License from time to time. Such new versions will be similar in spirit to the present version, but may differ in detail to address new problems or concerns. Each version is given a distinguishing version number. If the Program specifies a version number of the license which applies to it and "any later version", you have the option of following the terms and conditions either of that version or of any later version published by the Free Software Foundation. If the Program does not specify a version number of the license, you may choose any version ever published by the Free Software Foundation. 8. If you wish to incorporate parts of the Program into other free programs whose distribution conditions are different, write to the author to ask for permission. For software which is copyrighted by the Free Software Foundation, write to the Free Software Foundation; we sometimes make exceptions for this. Our decision will be guided by the two goals of preserving the free status of all derivatives of our free software and of promoting the sharing and reuse of software generally. NO WARRANTY 9. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 10. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. END OF TERMS AND CONDITIONS Appendix: How to Apply These Terms to Your New Programs If you develop a new program, and you want it to be of the greatest possible use to humanity, the best way to achieve this is to make it free software which everyone can redistribute and change under these terms. To do so, attach the following notices to the program. It is safest to attach them to the start of each source file to most effectively convey the exclusion of warranty; and each file should have at least the "copyright" line and a pointer to where the full notice is found. Copyright (C) 19yy This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 1, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301 USA Also add information on how to contact you by electronic and paper mail. If the program is interactive, make it output a short notice like this when it starts in an interactive mode: Gnomovision version 69, Copyright (C) 19xx name of author Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. This is free software, and you are welcome to redistribute it under certain conditions; type `show c' for details. The hypothetical commands `show w' and `show c' should show the appropriate parts of the General Public License. Of course, the commands you use may be called something other than `show w' and `show c'; they could even be mouse-clicks or menu items--whatever suits your program. You should also get your employer (if you work as a programmer) or your school, if any, to sign a "copyright disclaimer" for the program, if necessary. Here a sample; alter the names: Yoyodyne, Inc., hereby disclaims all copyright interest in the program `Gnomovision' (a program to direct compilers to make passes at assemblers) written by James Hacker. , 1 April 1989 Ty Coon, President of Vice That's all there is to it! --- The Perl Artistic License 1.0 --- This software is Copyright (c) 2026 by Alexis Sukrieh. This is free software, licensed under: The Perl Artistic License 1.0 The "Artistic License" Preamble The intent of this document is to state the conditions under which a Package may be copied, such that the Copyright Holder maintains some semblance of artistic control over the development of the package, while giving the users of the package the right to use and distribute the Package in a more-or-less customary fashion, plus the right to make reasonable modifications. Definitions: "Package" refers to the collection of files distributed by the Copyright Holder, and derivatives of that collection of files created through textual modification. "Standard Version" refers to such a Package if it has not been modified, or has been modified in accordance with the wishes of the Copyright Holder as specified below. "Copyright Holder" is whoever is named in the copyright or copyrights for the package. "You" is you, if you're thinking about copying or distributing this Package. "Reasonable copying fee" is whatever you can justify on the basis of media cost, duplication charges, time of people involved, and so on. (You will not be required to justify it to the Copyright Holder, but only to the computing community at large as a market that must bear the fee.) "Freely Available" means that no fee is charged for the item itself, though there may be fees involved in handling the item. It also means that recipients of the item may redistribute it under the same conditions they received it. 1. You may make and give away verbatim copies of the source form of the Standard Version of this Package without restriction, provided that you duplicate all of the original copyright notices and associated disclaimers. 2. You may apply bug fixes, portability fixes and other modifications derived from the Public Domain or from the Copyright Holder. A Package modified in such a way shall still be considered the Standard Version. 3. You may otherwise modify your copy of this Package in any way, provided that you insert a prominent notice in each changed file stating how and when you changed that file, and provided that you do at least ONE of the following: a) place your modifications in the Public Domain or otherwise make them Freely Available, such as by posting said modifications to Usenet or an equivalent medium, or placing the modifications on a major archive site such as uunet.uu.net, or by allowing the Copyright Holder to include your modifications in the Standard Version of the Package. b) use the modified Package only within your corporation or organization. c) rename any non-standard executables so the names do not conflict with standard executables, which must also be provided, and provide a separate manual page for each non-standard executable that clearly documents how it differs from the Standard Version. d) make other distribution arrangements with the Copyright Holder. 4. You may distribute the programs of this Package in object code or executable form, provided that you do at least ONE of the following: a) distribute a Standard Version of the executables and library files, together with instructions (in the manual page or equivalent) on where to get the Standard Version. b) accompany the distribution with the machine-readable source of the Package with your modifications. c) give non-standard executables non-standard names, and clearly document the differences in manual pages (or equivalent), together with instructions on where to get the Standard Version. d) make other distribution arrangements with the Copyright Holder. 5. You may charge a reasonable copying fee for any distribution of this Package. You may charge any fee you choose for support of this Package. You may not charge a fee for this Package itself. However, you may distribute this Package in aggregate with other (possibly commercial) programs as part of a larger (possibly commercial) software distribution provided that you do not advertise this Package as a product of your own. You may embed this Package's interpreter within an executable of yours (by linking); this shall be construed as a mere form of aggregation, provided that the complete Standard Version of the interpreter is so embedded. 6. The scripts and library files supplied as input to or produced as output from the programs of this Package do not automatically fall under the copyright of this Package, but belong to whoever generated them, and may be sold commercially, and may be aggregated with this Package. If such scripts or library files are aggregated with this Package via the so-called "undump" or "unexec" methods of producing a binary executable image, then distribution of such an image shall neither be construed as a distribution of this Package nor shall it fall under the restrictions of Paragraphs 3 and 4, provided that you do not represent such an executable image as a Standard Version of this Package. 7. C subroutines (or comparably compiled subroutines in other languages) supplied by you and linked into this Package in order to emulate subroutines and variables of the language defined by this Package shall not be considered part of this Package, but are the equivalent of input as in Paragraph 6, provided these subroutines do not change the language in any way that would cause it to fail the regression tests for the language. 8. Aggregation of this Package with a commercial distribution is always permitted provided that the use of this Package is embedded; that is, when no overt attempt is made to make this Package's interfaces visible to the end user of the commercial distribution. Such use shall not be construed as a distribution of this Package. 9. The name of the Copyright Holder may not be used to endorse or promote products derived from this software without specific prior written permission. 10. THIS PACKAGE IS PROVIDED "AS IS" AND WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. The End Changes100644001750001750 410715135450223 16134 0ustar00yanickyanick000000000000Dancer-Plugin-REST-0.12Revision history for 0.12 2026-01-25 [ENHANCEMENTS] - Move to Test2 for the testing. - use Dancer::HTTP as the source of truth for the http codes. [STATISTICS] - code churn: 15 files changed, 274 insertions(+), 89 deletions(-) 0.11 2014-03-25 [BUG FIXES] - Routes with ':id.:format' were not created properly. (GH#3, reported by garu) [STATISTICS] - code churn: 4 files changed, 68 insertions(+), 3 deletions(-) 0.10 2014-03-22 [BUG FIXES] - Requires Dancer v1.3111 or better. (GH#2, reported by OverlordQ) [ENHANCEMENTS] - 'resource' can now be used with a subset of its actions. [STATISTICS] - code churn: 4 files changed, 42 insertions(+), 25 deletions(-) 0.09 2014-03-11 [BUG FIXES] - Skip test if XML::Simple is not installed. [STATISTICS] - code churn: 2 files changed, 26 insertions(+), 3 deletions(-) 0.08 2014-03-10 [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) [STATISTICS] - code churn: 12 files changed, 172 insertions(+), 111 deletions(-) 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. META.yml100644001750001750 272415135450223 16115 0ustar00yanickyanick000000000000Dancer-Plugin-REST-0.12--- abstract: 'A plugin for writing RESTful apps with Dancer' author: - 'Alexis Sukrieh ' - 'Franck Cuny ' build_requires: Dancer::ModuleLoader: '0' Dancer::Test: '0' ExtUtils::MakeMaker: '0' File::Spec: '0' HTTP::Headers: '0' IO::Handle: '0' IPC::Open3: '0' Test2::Bundle::More: '0' Test2::V0: '0' Test::More: '0' configure_requires: ExtUtils::MakeMaker: '0' dynamic_config: 0 generated_by: 'Dist::Zilla version 6.033, CPAN::Meta::Converter version 2.150010' license: perl meta-spec: url: http://module-build.sourceforge.net/META-spec-v1.4.html version: '1.4' name: Dancer-Plugin-REST provides: Dancer::Plugin::REST: file: lib/Dancer/Plugin/REST.pm version: '0.12' requires: Carp: '0' Dancer: '1.3111' Dancer::HTTP: '0' Dancer::Plugin: '0' perl: v5.24.0 strict: '0' warnings: '0' resources: bugtracker: https://github.com/perldancer/Dancer-Plugin-REST/issues homepage: https://github.com/perldancer/Dancer-Plugin-REST repository: https://github.com/perldancer/Dancer-Plugin-REST.git version: '0.12' x_authority: cpan:SUKRIA x_contributor_covenant: version: 0.02 x_contributors: - 'Breno G. de Oliveira ' - 'James Aitken ' - 'Yanick Champoux ' - 'Yanick Champoux ' x_generated_by_perl: v5.38.0 x_serialization_backend: 'YAML::Tiny version 1.74' x_spdx_expression: 'Artistic-1.0-Perl OR GPL-1.0-or-later' MANIFEST100644001750001750 70515135450223 15752 0ustar00yanickyanick000000000000Dancer-Plugin-REST-0.12CODE_OF_CONDUCT.md CONTRIBUTING.md CONTRIBUTORS Changes INSTALL LICENSE MANIFEST META.json META.yml Makefile.PL README README.mkdn SECURITY.md SIGNATURE cpanfile doap.xml lib/Dancer/Plugin/REST.pm t/00-compile.t t/00-report-prereqs.dd t/00-report-prereqs.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/05_serializer_and_resource.t t/default-serializer.t t/two-posts.t xt/release/unused-vars.t doap.xml100644001750001750 1062715135450223 16332 0ustar00yanickyanick000000000000Dancer-Plugin-REST-0.12 Dancer-Plugin-REST A plugin for writing RESTful apps with Dancer Alexis Sukrieh Franck Cuny Breno G. de Oliveira James Aitken Yanick Champoux Yanick Champoux 0.0001_01 2010-05-06 0.02 2010-10-14 0.03 2010-10-18 0.04 2010-12-22 0.05 2011-03-04 0.06 2011-05-28 0.07 2011-11-01 0.08 2014-03-10 0.09 2014-03-11 0.10 2014-03-22 0.11 2014-03-25 Perl cpanfile100644001750001750 176315135450223 16352 0ustar00yanickyanick000000000000Dancer-Plugin-REST-0.12# This file is generated by Dist::Zilla::Plugin::CPANFile v6.033 # Do not edit this file directly. To change prereqs, edit the `dist.ini` file. requires "Carp" => "0"; requires "Dancer" => "1.3111"; requires "Dancer::HTTP" => "0"; requires "Dancer::Plugin" => "0"; requires "perl" => "v5.24.0"; requires "strict" => "0"; requires "warnings" => "0"; on 'test' => sub { requires "Dancer::ModuleLoader" => "0"; requires "Dancer::Test" => "0"; requires "ExtUtils::MakeMaker" => "0"; requires "File::Spec" => "0"; requires "HTTP::Headers" => "0"; requires "IO::Handle" => "0"; requires "IPC::Open3" => "0"; requires "Test2::Bundle::More" => "0"; requires "Test2::V0" => "0"; requires "Test::More" => "0"; }; on 'test' => sub { recommends "CPAN::Meta" => "2.120900"; }; on 'configure' => sub { requires "ExtUtils::MakeMaker" => "0"; }; on 'develop' => sub { requires "Software::Security::Policy::Individual" => "0"; requires "Test::More" => "0.96"; requires "Test::Vars" => "0"; }; META.json100644001750001750 511015135450223 16255 0ustar00yanickyanick000000000000Dancer-Plugin-REST-0.12{ "abstract" : "A plugin for writing RESTful apps with Dancer", "author" : [ "Alexis Sukrieh ", "Franck Cuny " ], "dynamic_config" : 0, "generated_by" : "Dist::Zilla version 6.033, CPAN::Meta::Converter version 2.150010", "license" : [ "perl_5" ], "meta-spec" : { "url" : "http://search.cpan.org/perldoc?CPAN::Meta::Spec", "version" : 2 }, "name" : "Dancer-Plugin-REST", "prereqs" : { "configure" : { "requires" : { "ExtUtils::MakeMaker" : "0" } }, "develop" : { "requires" : { "Software::Security::Policy::Individual" : "0", "Test::More" : "0.96", "Test::Vars" : "0" } }, "runtime" : { "requires" : { "Carp" : "0", "Dancer" : "1.3111", "Dancer::HTTP" : "0", "Dancer::Plugin" : "0", "perl" : "v5.24.0", "strict" : "0", "warnings" : "0" } }, "test" : { "recommends" : { "CPAN::Meta" : "2.120900" }, "requires" : { "Dancer::ModuleLoader" : "0", "Dancer::Test" : "0", "ExtUtils::MakeMaker" : "0", "File::Spec" : "0", "HTTP::Headers" : "0", "IO::Handle" : "0", "IPC::Open3" : "0", "Test2::Bundle::More" : "0", "Test2::V0" : "0", "Test::More" : "0" } } }, "provides" : { "Dancer::Plugin::REST" : { "file" : "lib/Dancer/Plugin/REST.pm", "version" : "0.12" } }, "release_status" : "stable", "resources" : { "bugtracker" : { "web" : "https://github.com/perldancer/Dancer-Plugin-REST/issues" }, "homepage" : "https://github.com/perldancer/Dancer-Plugin-REST", "repository" : { "type" : "git", "url" : "https://github.com/perldancer/Dancer-Plugin-REST.git", "web" : "https://github.com/perldancer/Dancer-Plugin-REST" } }, "version" : "0.12", "x_authority" : "cpan:SUKRIA", "x_contributor_covenant" : { "version" : 0.02 }, "x_contributors" : [ "Breno G. de Oliveira ", "James Aitken ", "Yanick Champoux ", "Yanick Champoux " ], "x_generated_by_perl" : "v5.38.0", "x_serialization_backend" : "Cpanel::JSON::XS version 4.37", "x_spdx_expression" : "Artistic-1.0-Perl OR GPL-1.0-or-later" } SIGNATURE100644001750001750 617115135450223 16130 0ustar00yanickyanick000000000000Dancer-Plugin-REST-0.12This file contains message digests of all files listed in MANIFEST, signed via the Module::Signature module, version 0.88. To verify the content in this distribution, first make sure you have Module::Signature installed, then type: % cpansign -v It will check each file's integrity, as well as the signature's validity. If "==> Signature verified OK! <==" is not displayed, the distribution may already have been compromised, and you should not run its Makefile.PL or Build.PL. -----BEGIN PGP SIGNED MESSAGE----- Hash: RIPEMD160 SHA256 22699642bd14b813d609969fb2226d857e65105a127d392e30e9d72e879f8daf CODE_OF_CONDUCT.md SHA256 327cd3c1bff19ecf0bd0ef3b10943617d89972e0c1ee3e22db49a091761219d9 CONTRIBUTING.md SHA256 7ca824cd91a782b8a4d79ac284d09585b82b7a2fe5ada177a95a84f896c5862f CONTRIBUTORS SHA256 0561e9eee7068671df40da04f4a2b8c4ed81fe373c4c7bffaf4ff20929363c79 Changes SHA256 752c219628daaac2997645007ee12ed95d816b24ac746c4ab8859d665923a1b1 INSTALL SHA256 89dfd4217d950f05a6107de3a6c260461f3304d27b54472195455a59b5bb945e LICENSE SHA256 e5293b4e2613a47bf12ec8eb91fdbc5ec28828c887817cb3fd95d7ef32c8586c MANIFEST SHA256 e6ba5cc075c6590b445be2f13691dd3b4bdf484ab35714b01066249e7d64b211 META.json SHA256 87b26296b73f67a36b94893494c6f2e9897ab71fd0a7da0aca4effab69cd0220 META.yml SHA256 875c1de58e27fb3acb0cba5f922df45d2ff66bb671e59409aec75b0d2f4ed049 Makefile.PL SHA256 2442c8b4fd78a52765b974789a85c02511bd3f4f1c9cca99cea6fb03bdffebbb README SHA256 f934dfa060422b3af5173ae1930a396a5e0478e70b5a5b716347bec0f4ccfd3e README.mkdn SHA256 7d4cecc23e72177c4b39092c8c902d03acd6906b9dec37846990da3b06250d0d SECURITY.md SHA256 78022e50b3613fc0314f4dbc6765e75fd23b84c87d605c95428d7f677ccc71d9 cpanfile SHA256 54f4c51b28e93fae671c8cfde1bc67137132c6650d5767149bf6a0697853becf doap.xml SHA256 9cf94239d97e40ef0d9c1f8c04799304b18923d95c4d419a9231a412c5f77fdb lib/Dancer/Plugin/REST.pm SHA256 233e9552ec59db6140881a7faa53a8cc227c115e354dd7203d73ad4a8f698e40 t/00-compile.t SHA256 08b068491b947f1e6bc0170925d59e70695753f3c5eb83d9c2fd1dd24a6a265b t/00-report-prereqs.dd SHA256 5996417e8ae9973f82860dcf6d5f180d285d5c4b046e0346d06ed22802a3452b t/00-report-prereqs.t SHA256 b4d10a5a88d7ff351d66d3faf70cfe320d19c52f3e2f5ce9761ec63111c77c53 t/01_base.t SHA256 44dd118790ec2aba1703c169276890dcf482618a3171a8484a1a4995395f5d82 t/02_prepare_serializer_for_format.t SHA256 74242fee4e1cc86775dba87e86241aa6f4d9d4afa99444f72443f012eb353733 t/03_resource.t SHA256 aa1d6394549c4ed743715d751fe27a1acd3f8a0e9120bcfe6c9902c69ea7138f t/04_helpers.t SHA256 973f98409b6b8f37bcd94d781bc9b587915fb23d0aaa3da2a5926885f68f7265 t/04_plugin_settings.t SHA256 73ebef58f0ab696c95e455b3ffecb388a647424873deb52bfb2a1f11ebfe594f t/05_serializer_and_resource.t SHA256 2821a2fdd984218520a7c36952ed35bbdcc565e13df12fe454707829c1e7f8ad t/default-serializer.t SHA256 dcb75670fb7002e645f1b77e29eee567ce9fa72a5e3f096867416a732153917e t/two-posts.t SHA256 d34f839d8340478663bd6ae59c72760d7e1a2b7a2d4879ad1ec97db1a2271b2f xt/release/unused-vars.t -----BEGIN PGP SIGNATURE----- iF0EAREDAB0WIQS4RMr2LZlyA/IlbHHfgfB/4bALjAUCaXZQkgAKCRDfgfB/4bAL jI9hAKDmOZYqdRL5HwyuyTagdaVOlQUJmwCg0xCxHr3g1irlqJCkEY3xqErrL60= =1uns -----END PGP SIGNATURE----- Makefile.PL100644001750001750 335615135450223 16620 0ustar00yanickyanick000000000000Dancer-Plugin-REST-0.12# This file was automatically generated by Dist::Zilla::Plugin::MakeMaker v6.033. use strict; use warnings; use 5.024000; use ExtUtils::MakeMaker; my %WriteMakefileArgs = ( "ABSTRACT" => "A plugin for writing RESTful apps with Dancer", "AUTHOR" => "Alexis Sukrieh , Franck Cuny ", "CONFIGURE_REQUIRES" => { "ExtUtils::MakeMaker" => 0 }, "DISTNAME" => "Dancer-Plugin-REST", "LICENSE" => "perl", "MIN_PERL_VERSION" => "5.024000", "NAME" => "Dancer::Plugin::REST", "PREREQ_PM" => { "Carp" => 0, "Dancer" => "1.3111", "Dancer::HTTP" => 0, "Dancer::Plugin" => 0, "strict" => 0, "warnings" => 0 }, "TEST_REQUIRES" => { "Dancer::ModuleLoader" => 0, "Dancer::Test" => 0, "ExtUtils::MakeMaker" => 0, "File::Spec" => 0, "HTTP::Headers" => 0, "IO::Handle" => 0, "IPC::Open3" => 0, "Test2::Bundle::More" => 0, "Test2::V0" => 0, "Test::More" => 0 }, "VERSION" => "0.12", "test" => { "TESTS" => "t/*.t" } ); my %FallbackPrereqs = ( "Carp" => 0, "Dancer" => "1.3111", "Dancer::HTTP" => 0, "Dancer::ModuleLoader" => 0, "Dancer::Plugin" => 0, "Dancer::Test" => 0, "ExtUtils::MakeMaker" => 0, "File::Spec" => 0, "HTTP::Headers" => 0, "IO::Handle" => 0, "IPC::Open3" => 0, "Test2::Bundle::More" => 0, "Test2::V0" => 0, "Test::More" => 0, "strict" => 0, "warnings" => 0 ); unless ( eval { ExtUtils::MakeMaker->VERSION(6.63_03) } ) { delete $WriteMakefileArgs{TEST_REQUIRES}; delete $WriteMakefileArgs{BUILD_REQUIRES}; $WriteMakefileArgs{PREREQ_PM} = \%FallbackPrereqs; } delete $WriteMakefileArgs{CONFIGURE_REQUIRES} unless eval { ExtUtils::MakeMaker->VERSION(6.52) }; WriteMakefile(%WriteMakefileArgs); README.mkdn100644001750001750 567415135450223 16463 0ustar00yanickyanick000000000000Dancer-Plugin-REST-0.12# NAME Dancer::Plugin::REST - A plugin for writing RESTful apps with Dancer # VERSION version 0.12 # DESCRIPTION This plugin helps you write a RESTful webservice with Dancer. # SYNOPSYS ```perl package MyWebService; use Dancer; use Dancer::Plugin::REST; prepare_serializer_for_format; get '/user/:id.:format' => sub { User->find(params->{id}); }; # curl http://mywebservice/user/42.json { "id": 42, "name": "John Foo", email: "john.foo@example.com"} # curl http://mywebservice/user/42.yml -- id: 42 name: "John Foo" email: "john.foo@example.com" ``` # KEYWORDS ## prepare\_serializer\_for\_format When this pragma is used, a before filter is set by the plugin to automatically change the serializer when a format is detected in the URI. That means that each route you define with a **:format** token will trigger a serializer definition, if the format is known. This lets you define all the REST actions you like as regular Dancer route handlers, without explicitly handling the outgoing data format. ## resource This keyword lets you declare a resource your application will handle. ```perl 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} }, update => sub { # update user with params->{user} }; # this defines the following routes: # GET /user/:id # GET /user/:id.:format # POST /user # POST /user.:format # DELETE /user/:id # DELETE /user/:id.:format # PUT /user/:id # PUT /user/:id.:format ``` ## helpers Some helpers are available. This helper will set an appropriate HTTP status for you. ### status\_ok ```perl status_ok({users => {...}}); ``` Set the HTTP status to 200 ### status\_created ```perl status_created({users => {...}}); ``` Set the HTTP status to 201 ### status\_accepted ```perl status_accepted({users => {...}}); ``` Set the HTTP status to 202 ### status\_bad\_request ```perl status_bad_request("user foo can't be found"); ``` Set the HTTP status to 400. This function as for argument a scalar that will be used under the key **error**. ### status\_not\_found ```perl status_not_found("users doesn't exists"); ``` Set the HTTP status to 404. This function as for argument a scalar that will be used under the key **error**. # LICENCE This module is released under the same terms as Perl itself. # AUTHORS This module has been written by Alexis Sukrieh `` and Franck Cuny. # SEE ALSO [Dancer](https://metacpan.org/pod/Dancer) [http://en.wikipedia.org/wiki/Representational\_State\_Transfer](http://en.wikipedia.org/wiki/Representational_State_Transfer) # AUTHORS - Alexis Sukrieh - Franck Cuny # COPYRIGHT AND LICENSE This software is copyright (c) 2026 by Alexis Sukrieh. This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself. t000755001750001750 015135450223 14742 5ustar00yanickyanick000000000000Dancer-Plugin-REST-0.1201_base.t100644001750001750 11615135450223 16457 0ustar00yanickyanick000000000000Dancer-Plugin-REST-0.12/tuse Test2::V0; use Dancer::Plugin::REST; ok "module loaded"; done_testing; SECURITY.md100644001750001750 1020315135450223 16444 0ustar00yanickyanick000000000000Dancer-Plugin-REST-0.12# Security Policy for the Dancer-Plugin-REST distribution. Report security issues by email to Alexis Sukrieh , Franck Cuny . This is the Security Policy for Dancer-Plugin-REST. This text is based on the CPAN Security Group's Guidelines for Adding a Security Policy to Perl Distributions (version 1.3.0) https://security.metacpan.org/docs/guides/security-policy-for-authors.html # How to Report a Security Vulnerability Security vulnerabilities can be reported to the current Dancer-Plugin-REST maintainers by email to Alexis Sukrieh , Franck Cuny . Please include as many details as possible, including code samples or test cases, so that we can reproduce the issue. Check that your report does not expose any sensitive data, such as passwords, tokens, or personal information. If you would like any help with triaging the issue, or if the issue is being actively exploited, please copy the report to the CPAN Security Group (CPANSec) at . Please *do not* use the public issue reporting system on RT or GitHub issues for reporting security vulnerabilities. Please do not disclose the security vulnerability in public forums until past any proposed date for public disclosure, or it has been made public by the maintainers or CPANSec. That includes patches or pull requests. For more information, see [Report a Security Issue](https://security.metacpan.org/docs/report.html) on the CPANSec website. ## Response to Reports The maintainer(s) aim to acknowledge your security report as soon as possible. However, this project is maintained by a single person in their spare time, and they cannot guarantee a rapid response. If you have not received a response from them within 1 month, then please send a reminder to them and copy the report to CPANSec at . Please note that the initial response to your report will be an acknowledgement, with a possible query for more information. It will not necessarily include any fixes for the issue. The project maintainer(s) may forward this issue to the security contacts for other projects where we believe it is relevant. This may include embedded libraries, system libraries, prerequisite modules or downstream software that uses this software. They may also forward this issue to CPANSec. # Which Software This Policy Applies To Any security vulnerabilities in Dancer-Plugin-REST are covered by this policy. Security vulnerabilities in versions of any libraries that are included in Dancer-Plugin-REST are also covered by this policy. Security vulnerabilities are considered anything that allows users to execute unauthorised code, access unauthorised resources, or to have an adverse impact on accessibility or performance of a system. Security vulnerabilities in upstream software (prerequisite modules or system libraries, or in Perl), are not covered by this policy unless they affect Dancer-Plugin-REST, or Dancer-Plugin-REST can be used to exploit vulnerabilities in them. Security vulnerabilities in downstream software (any software that uses Dancer-Plugin-REST, or plugins to it that are not included with the Dancer-Plugin-REST distribution) are not covered by this policy. ## Supported Versions of Dancer-Plugin-REST The maintainer(s) will only commit to releasing security fixes for the latest version of Dancer-Plugin-REST. Note that the Dancer-Plugin-REST project only supports major versions of Perl released in the past 5 years, even though Dancer-Plugin-REST will run on older versions of Perl. If a security fix requires us to increase the minimum version of Perl that is supported, then we may do so. # Installation and Usage Issues The distribution metadata specifies minimum versions of prerequisites that are required for Dancer-Plugin-REST to work. However, some of these prerequisites may have security vulnerabilities, and you should ensure that you are using up-to-date versions of these prerequisites. Where security vulnerabilities are known, the metadata may indicate newer versions as recommended. ## Usage Please see the software documentation for further information. CONTRIBUTORS100644001750001750 53615135450223 16503 0ustar00yanickyanick000000000000Dancer-Plugin-REST-0.12 # DANCER-PLUGIN-REST CONTRIBUTORS # This is the (likely incomplete) list of people who have helped make this distribution what it is, either via code contributions, patches, bug reports, help with troubleshooting, etc. A huge 'thank you' to all of them. * Breno G. de Oliveira * James Aitken * Yanick Champoux * Yanick Champoux two-posts.t100644001750001750 124315135450223 17246 0ustar00yanickyanick000000000000Dancer-Plugin-REST-0.12/tuse strict; use warnings; { package Foo; use Dancer; use Dancer::Plugin::REST; prepare_serializer_for_format; post '/foo.:format' => sub { return params; }; } use Test2::Bundle::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/; } 00-compile.t100644001750001750 264315135450223 17141 0ustar00yanickyanick000000000000Dancer-Plugin-REST-0.12/tuse 5.006; use strict; use warnings; # this test was generated with Dist::Zilla::Plugin::Test::Compile 2.058 use Test::More; plan tests => 1 + ($ENV{AUTHOR_TESTING} ? 1 : 0); my @module_files = ( 'Dancer/Plugin/REST.pm' ); # no fake home requested my @switches = ( -d 'blib' ? '-Mblib' : '-Ilib', ); use File::Spec; use IPC::Open3; use IO::Handle; open my $stdin, '<', File::Spec->devnull or die "can't open devnull: $!"; my @warnings; for my $lib (@module_files) { # see L my $stderr = IO::Handle->new; diag('Running: ', join(', ', map { my $str = $_; $str =~ s/'/\\'/g; q{'} . $str . q{'} } $^X, @switches, '-e', "require q[$lib]")) if $ENV{PERL_COMPILE_TEST_DEBUG}; my $pid = open3($stdin, '>&STDERR', $stderr, $^X, @switches, '-e', "require q[$lib]"); binmode $stderr, ':crlf' if $^O eq 'MSWin32'; my @_warnings = <$stderr>; waitpid($pid, 0); is($?, 0, "$lib loaded ok"); shift @_warnings if @_warnings and $_warnings[0] =~ /^Using .*\bblib/ and not eval { +require blib; blib->VERSION('1.01') }; if (@_warnings) { warn @_warnings; push @warnings, @_warnings; } } is(scalar(@warnings), 0, 'no warnings found') or diag 'got warnings: ', ( Test::More->can('explain') ? Test::More::explain(\@warnings) : join("\n", '', @warnings) ) if $ENV{AUTHOR_TESTING}; 04_helpers.t100644001750001750 560415135450223 17241 0ustar00yanickyanick000000000000Dancer-Plugin-REST-0.12/tuse strict; use warnings; use Dancer::ModuleLoader; use Test2::Bundle::More; plan tests => 16; { package Webservice; use Dancer; use Dancer::Plugin::REST; resource user => 'get' => \&on_get_user, 'create' => \&on_create_user, 'delete' => \&on_delete_user, 'update' => \&on_update_user; my $users = {}; my $last_id = 0; sub on_get_user { my $id = params->{'id'}; return status_bad_request('id is missing') if !defined $users->{$id}; status_ok( { user => $users->{$id} } ); } sub on_create_user { my $id = ++$last_id; my $user = params('body'); $user->{id} = $id; $users->{$id} = $user; status_created( { user => $users->{$id} } ); } sub on_delete_user { my $id = params->{'id'}; my $deleted = $users->{$id}; delete $users->{$id}; status_accepted( { user => $deleted } ); } sub on_update_user { my $id = params->{'id'}; my $user = $users->{$id}; return status_not_found("user undef") unless defined $user; $users->{$id} = { %$user, %{ params('body') } }; status_accepted { user => $users->{$id} }; } } use Dancer::Test; my $r = dancer_response( GET => '/user/1' ); is $r->{status}, 400, 'HTTP code is 400'; is $r->{content}->{error}, 'id is missing', 'Valid content'; $r = dancer_response( POST => '/user', { body => { name => 'Alexis' } } ); is $r->{status}, 201, 'HTTP code is 201'; is_deeply $r->{content}, { user => { id => 1, name => "Alexis" } }, "create user works"; $r = dancer_response( GET => '/user/1' ); is $r->{status}, 200, 'HTTP code is 200'; is_deeply $r->{content}, { user => { id => 1, name => 'Alexis' } }, "user 1 is defined"; $r = dancer_response( PUT => '/user/1', { body => { nick => 'sukria', name => 'Alexis Sukrieh' } } ); is $r->{status}, 202, 'HTTP code is 202'; is_deeply $r->{content}, { user => { id => 1, name => 'Alexis Sukrieh', nick => 'sukria' } }, "user 1 is updated"; $r = dancer_response( PUT => '/user/23', { body => { nick => 'john doe', name => 'John Doe' } } ); is $r->{status}, 404, 'HTTP code is 404'; is_deeply $r->{content}->{error}, 'user undef', 'valid content'; $r = dancer_response( DELETE => '/user/1' ); is_deeply $r->{content}, { user => { id => 1, name => 'Alexis Sukrieh', nick => 'sukria' } }, "user 1 is deleted"; is $r->{status}, 202, 'HTTP code is 202'; $r = dancer_response( GET => '/user/1' ); is $r->{status}, 400, 'HTTP code is 400'; is_deeply $r->{content}->{error}, 'id is missing', 'valid response'; $r = dancer_response( POST => '/user', { body => { name => 'Franck Cuny' } } ); is_deeply $r->{content}, { user => { id => 2, name => "Franck Cuny" } }, "id is correctly increased"; is $r->{status}, 201, 'HTTP code is 201'; CONTRIBUTING.md100644001750001750 434615135450223 17077 0ustar00yanickyanick000000000000Dancer-Plugin-REST-0.12 # Contributing to Dancer-Plugin-REST So you want to contribute to this package? Or fork it? Or play with it, or whatever? Excellent! Here, let me try to make it easier for you. ## Dist::Zilla and branch structure This package, like many of mine, uses [Dist::Zilla](https://metacpan.org/dist/Dist-Zilla). Dist::Zilla (`dzil` to its friends) is a distribution builder that helps (tremendously) with the nitty gritty of grooming and releasing packages to CPAN. It tidies up the documentation, add boilerplate files, update versions, and... do a *bunch* of other things. Because it does so much, it can be scary for some people. But it really doesn't need to be. This repository has two core branches: * `main` -- the working branch, holding the pre-dzil-munging code. * `releases` -- contains the dzil-munged code released to CPAN. Which means that if you don't want to bother with Dist::Zilla at all, checkout `releases` and work on it. Since it's the "real" code that made it to CPAN, all it working -- the package itself, the tests, everything. And totally feel free to use this branch as a base for a PR. I'll be very grateful for the work, and I'll take on the last step of porting the patching to `main`, noooo problem. ### I'm brave, I want to be on `main` Good for you! The good news is that dzil mostly tinker with stuff the working code doesn't care about, so you probably won't have to do anything special. In most cases, tinkering with the code will look like: $ cpanm --installdeps . $ ... tinker, tinker ... $ prove -l t Now, if you want to generate the CPAN-ready tarball, or go full YANICK on things. You'll have to install both Dist::Zilla and my plugin bundle: $ cpanm Dist::Zilla Dist::Zilla::PluginBundle::YANICK and then you should be able to do all things dzilly; # generate the tarball $ dzil build # run all the tests on the final code $ dzil test Now, a honest caveat: `Dist::Zilla::PluginBundle::YANICK` is tailored to my exact needs; it does a lot, and some of it is not guaranteed to work on somebody else's system. If you try to use it and you hit something weird, just let me know, and I'll do my best to help you. Aaaand that's pretty all I think you need to get started. Good luck! :-) 03_resource.t100644001750001750 530315135450223 17421 0ustar00yanickyanick000000000000Dancer-Plugin-REST-0.12/tuse strict; use warnings; use Dancer::ModuleLoader; use Test2::Bundle::More; # Dancer::Test had a bug in version previous 1.3059_01 that prevent this test # from running correctly. my $dancer_version = eval "\$Dancer::VERSION"; $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 tests => 8; { package Webservice; use Dancer; use Dancer::Plugin::REST; use Test2::Bundle::More; resource user => 'get' => \&on_get_user, 'create' => \&on_create_user, 'delete' => \&on_delete_user, 'update' => \&on_update_user; my $users = {}; my $last_id = 0; sub on_get_user { my $id = params->{'id'}; { user => $users->{$id} }; } sub on_create_user { my $id = ++$last_id; my $user = params('body'); $user->{id} = $id; $users->{$id} = $user; { user => $users->{$id} }; } sub on_delete_user { my $id = params->{'id'}; my $deleted = $users->{$id}; delete $users->{$id}; { user => $deleted }; } sub on_update_user { my $id = params->{'id'}; my $user = $users->{$id}; return { user => undef } unless defined $user; $users->{$id} = { %$user, %{params('body')} }; { user => $users->{$id} }; } eval { resource failure => get => sub { 'GET' }, woobly => sub { }, }; like $@, qr{action 'woobly' not recognized}, "resource must have 4 hooks"; } use Dancer::Test; my $r = dancer_response(GET => '/user/1'); is_deeply $r->{content}, {user => undef}, "user 1 is not defined"; $r = dancer_response(POST => '/user', { body => {name => 'Alexis' }}); is_deeply $r->{content}, { user => { id => 1, name => "Alexis" } }, "create user works"; $r = dancer_response(GET => '/user/1'); is_deeply $r->{content}, {user => { id => 1, name => 'Alexis'}}, "user 1 is defined"; $r = dancer_response(PUT => '/user/1', { body => { nick => 'sukria', name => 'Alexis Sukrieh' } }); is_deeply $r->{content}, {user => { id => 1, name => 'Alexis Sukrieh', nick => 'sukria'}}, "user 1 is updated"; $r = dancer_response(DELETE => '/user/1'); is_deeply $r->{content}, {user => { id => 1, name => 'Alexis Sukrieh', nick => 'sukria'}}, "user 1 is deleted"; $r = dancer_response(GET => '/user/1'); is_deeply $r->{content}, {user => undef}, "user 1 is not defined"; $r = dancer_response(POST => '/user', { body => { name => 'Franck Cuny' } }); is_deeply $r->{content}, { user => { id => 2, name => "Franck Cuny" } }, "id is correctly increased"; CODE_OF_CONDUCT.md100644001750001750 1214315135450223 17457 0ustar00yanickyanick000000000000Dancer-Plugin-REST-0.12# Contributor Covenant Code of Conduct ## Our Pledge We as members, contributors, and leaders pledge to make participation in our community a harassment-free experience for everyone, regardless of age, body size, visible or invisible disability, ethnicity, sex characteristics, gender identity and expression, level of experience, education, socio-economic status, nationality, personal appearance, race, religion, or sexual identity and orientation. We pledge to act and interact in ways that contribute to an open, welcoming, diverse, inclusive, and healthy community. ## Our Standards Examples of behavior that contributes to a positive environment for our community include: * Demonstrating empathy and kindness toward other people * Being respectful of differing opinions, viewpoints, and experiences * Giving and gracefully accepting constructive feedback * Accepting responsibility and apologizing to those affected by our mistakes, and learning from the experience * Focusing on what is best not just for us as individuals, but for the overall community Examples of unacceptable behavior include: * The use of sexualized language or imagery, and sexual attention or advances of any kind * Trolling, insulting or derogatory comments, and personal or political attacks * Public or private harassment * Publishing others' private information, such as a physical or email address, without their explicit permission * Other conduct which could reasonably be considered inappropriate in a professional setting ## Enforcement Responsibilities Community leaders are responsible for clarifying and enforcing our standards of acceptable behavior and will take appropriate and fair corrective action in response to any behavior that they deem inappropriate, threatening, offensive, or harmful. Community leaders have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct, and will communicate reasons for moderation decisions when appropriate. ## Scope This Code of Conduct applies within all community spaces, and also applies when an individual is officially representing the community in public spaces. Examples of representing our community include using an official e-mail address, posting via an official social media account, or acting as an appointed representative at an online or offline event. ## Enforcement Instances of abusive, harassing, or otherwise unacceptable behavior may be reported to the community leaders responsible for enforcement at sukria@sukria.net. All complaints will be reviewed and investigated promptly and fairly. All community leaders are obligated to respect the privacy and security of the reporter of any incident. ## Enforcement Guidelines Community leaders will follow these Community Impact Guidelines in determining the consequences for any action they deem in violation of this Code of Conduct: ### 1. Correction **Community Impact**: Use of inappropriate language or other behavior deemed unprofessional or unwelcome in the community. **Consequence**: A private, written warning from community leaders, providing clarity around the nature of the violation and an explanation of why the behavior was inappropriate. A public apology may be requested. ### 2. Warning **Community Impact**: A violation through a single incident or series of actions. **Consequence**: A warning with consequences for continued behavior. No interaction with the people involved, including unsolicited interaction with those enforcing the Code of Conduct, for a specified period of time. This includes avoiding interactions in community spaces as well as external channels like social media. Violating these terms may lead to a temporary or permanent ban. ### 3. Temporary Ban **Community Impact**: A serious violation of community standards, including sustained inappropriate behavior. **Consequence**: A temporary ban from any sort of interaction or public communication with the community for a specified period of time. No public or private interaction with the people involved, including unsolicited interaction with those enforcing the Code of Conduct, is allowed during this period. Violating these terms may lead to a permanent ban. ### 4. Permanent Ban **Community Impact**: Demonstrating a pattern of violation of community standards, including sustained inappropriate behavior, harassment of an individual, or aggression toward or disparagement of classes of individuals. **Consequence**: A permanent ban from any sort of public interaction within the community. ## Attribution This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 2.0, available at https://www.contributor-covenant.org/version/2/0/code_of_conduct.html. Community Impact Guidelines were inspired by [Mozilla's code of conduct enforcement ladder](https://github.com/mozilla/diversity). [homepage]: https://www.contributor-covenant.org For answers to common questions about this code of conduct, see the FAQ at https://www.contributor-covenant.org/faq. Translations are available at https://www.contributor-covenant.org/translations. 00-report-prereqs.t100644001750001750 1360115135450223 20517 0ustar00yanickyanick000000000000Dancer-Plugin-REST-0.12/t#!perl use strict; use warnings; # This test was generated by Dist::Zilla::Plugin::Test::ReportPrereqs 0.029 use Test::More tests => 1; use ExtUtils::MakeMaker; use File::Spec; # from $version::LAX my $lax_version_re = qr/(?: undef | (?: (?:[0-9]+) (?: \. | (?:\.[0-9]+) (?:_[0-9]+)? )? | (?:\.[0-9]+) (?:_[0-9]+)? ) | (?: v (?:[0-9]+) (?: (?:\.[0-9]+)+ (?:_[0-9]+)? )? | (?:[0-9]+)? (?:\.[0-9]+){2,} (?:_[0-9]+)? ) )/x; # hide optional CPAN::Meta modules from prereq scanner # and check if they are available my $cpan_meta = "CPAN::Meta"; my $cpan_meta_pre = "CPAN::Meta::Prereqs"; my $HAS_CPAN_META = eval "require $cpan_meta; $cpan_meta->VERSION('2.120900')" && eval "require $cpan_meta_pre"; ## no critic # Verify requirements? my $DO_VERIFY_PREREQS = 1; sub _max { my $max = shift; $max = ( $_ > $max ) ? $_ : $max for @_; return $max; } sub _merge_prereqs { my ($collector, $prereqs) = @_; # CPAN::Meta::Prereqs object if (ref $collector eq $cpan_meta_pre) { return $collector->with_merged_prereqs( CPAN::Meta::Prereqs->new( $prereqs ) ); } # Raw hashrefs for my $phase ( keys %$prereqs ) { for my $type ( keys %{ $prereqs->{$phase} } ) { for my $module ( keys %{ $prereqs->{$phase}{$type} } ) { $collector->{$phase}{$type}{$module} = $prereqs->{$phase}{$type}{$module}; } } } return $collector; } my @include = qw( ); my @exclude = qw( ); # Add static prereqs to the included modules list my $static_prereqs = do './t/00-report-prereqs.dd'; # Merge all prereqs (either with ::Prereqs or a hashref) my $full_prereqs = _merge_prereqs( ( $HAS_CPAN_META ? $cpan_meta_pre->new : {} ), $static_prereqs ); # Add dynamic prereqs to the included modules list (if we can) my ($source) = grep { -f } 'MYMETA.json', 'MYMETA.yml'; my $cpan_meta_error; if ( $source && $HAS_CPAN_META && (my $meta = eval { CPAN::Meta->load_file($source) } ) ) { $full_prereqs = _merge_prereqs($full_prereqs, $meta->prereqs); } else { $cpan_meta_error = $@; # capture error from CPAN::Meta->load_file($source) $source = 'static metadata'; } my @full_reports; my @dep_errors; my $req_hash = $HAS_CPAN_META ? $full_prereqs->as_string_hash : $full_prereqs; # Add static includes into a fake section for my $mod (@include) { $req_hash->{other}{modules}{$mod} = 0; } for my $phase ( qw(configure build test runtime develop other) ) { next unless $req_hash->{$phase}; next if ($phase eq 'develop' and not $ENV{AUTHOR_TESTING}); for my $type ( qw(requires recommends suggests conflicts modules) ) { next unless $req_hash->{$phase}{$type}; my $title = ucfirst($phase).' '.ucfirst($type); my @reports = [qw/Module Want Have/]; for my $mod ( sort keys %{ $req_hash->{$phase}{$type} } ) { next if grep { $_ eq $mod } @exclude; my $want = $req_hash->{$phase}{$type}{$mod}; $want = "undef" unless defined $want; $want = "any" if !$want && $want == 0; if ($mod eq 'perl') { push @reports, ['perl', $want, $]]; next; } my $req_string = $want eq 'any' ? 'any version required' : "version '$want' required"; my $file = $mod; $file =~ s{::}{/}g; $file .= ".pm"; my ($prefix) = grep { -e File::Spec->catfile($_, $file) } @INC; if ($prefix) { my $have = MM->parse_version( File::Spec->catfile($prefix, $file) ); $have = "undef" unless defined $have; push @reports, [$mod, $want, $have]; if ( $DO_VERIFY_PREREQS && $HAS_CPAN_META && $type eq 'requires' ) { if ( $have !~ /\A$lax_version_re\z/ ) { push @dep_errors, "$mod version '$have' cannot be parsed ($req_string)"; } elsif ( ! $full_prereqs->requirements_for( $phase, $type )->accepts_module( $mod => $have ) ) { push @dep_errors, "$mod version '$have' is not in required range '$want'"; } } } else { push @reports, [$mod, $want, "missing"]; if ( $DO_VERIFY_PREREQS && $type eq 'requires' ) { push @dep_errors, "$mod is not installed ($req_string)"; } } } if ( @reports ) { push @full_reports, "=== $title ===\n\n"; my $ml = _max( map { length $_->[0] } @reports ); my $wl = _max( map { length $_->[1] } @reports ); my $hl = _max( map { length $_->[2] } @reports ); if ($type eq 'modules') { splice @reports, 1, 0, ["-" x $ml, "", "-" x $hl]; push @full_reports, map { sprintf(" %*s %*s\n", -$ml, $_->[0], $hl, $_->[2]) } @reports; } else { splice @reports, 1, 0, ["-" x $ml, "-" x $wl, "-" x $hl]; push @full_reports, map { sprintf(" %*s %*s %*s\n", -$ml, $_->[0], $wl, $_->[1], $hl, $_->[2]) } @reports; } push @full_reports, "\n"; } } } if ( @full_reports ) { diag "\nVersions for all modules listed in $source (including optional ones):\n\n", @full_reports; } if ( $cpan_meta_error || @dep_errors ) { diag "\n*** WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING ***\n"; } if ( $cpan_meta_error ) { my ($orig_source) = grep { -f } 'MYMETA.json', 'MYMETA.yml'; diag "\nCPAN::Meta->load_file('$orig_source') failed with: $cpan_meta_error\n"; } if ( @dep_errors ) { diag join("\n", "\nThe following REQUIRED prerequisites were not satisfied:\n", @dep_errors, "\n" ); } pass('Reported prereqs'); # vim: ts=4 sts=4 sw=4 et: 04_plugin_settings.t100644001750001750 300715135450223 21010 0ustar00yanickyanick000000000000Dancer-Plugin-REST-0.12/tuse strict; use warnings; use Dancer::ModuleLoader; use Test2::Bundle::More; plan skip_all => "JSON is needed for this test" unless Dancer::ModuleLoader->load('JSON'); plan skip_all => "YAML is needed for this test" unless Dancer::ModuleLoader->load('YAML'); my $data = { foo => 42 }; my $json = JSON::encode_json($data); my $yaml = YAML::Dump($data); { package Webservice; use Dancer; use Dancer::Plugin::REST; set environment => 'test'; set show_errors => 1; prepare_serializer_for_format; get '/' => sub { "root" }; get '/:something.:format' => sub { $data; }; } use Dancer::Test; my @tests = ( { request => [GET => '/'], response => 'root', }, { request => [GET => '/foo.json'], response => $json, }, { request => [GET => '/foo.yml'], response => $yaml, }, { request => [GET => '/'], response => 'root', }, ); plan tests => 6; for my $test ( @tests ) { my $response = dancer_response(@{$test->{request}}); if (ref($test->{response})) { like( $response->{content}, $test->{response}, "response looks good for '@{$test->{request}}'" ); } else { is( $response->{content}, $test->{response}, "response looks good for '@{$test->{request}}'" ); } } my $response = dancer_response( GET => '/foo.foobar' ); is $response->status => 404, 'error code 404'; like $response->content => qr/unsupported format requested: foobar/ms; default-serializer.t100644001750001750 124115135450223 21060 0ustar00yanickyanick000000000000Dancer-Plugin-REST-0.12/tuse strict; use warnings; use Test2::Bundle::More; plan skip_all => 'XML::Simple required' unless eval "use XML::Simple; 1"; plan tests => 3; { use Dancer ':tests'; use Dancer::Plugin::REST; prepare_serializer_for_format; set serializer => 'XML'; get '/foo' => sub { return { hello => 'world' }; }; get '/foo.:format' => sub { return { hello => 'world' }; }; } use Dancer::Test; response_content_like '/foo' => qr/ qr/"hello"\s*:\s*"world"/, "ask for JSON"; response_content_like '/foo' => qr/ { 'requires' => { 'ExtUtils::MakeMaker' => '0' } }, 'develop' => { 'requires' => { 'Software::Security::Policy::Individual' => '0', 'Test::More' => '0.96', 'Test::Vars' => '0' } }, 'runtime' => { 'requires' => { 'Carp' => '0', 'Dancer' => '1.3111', 'Dancer::HTTP' => '0', 'Dancer::Plugin' => '0', 'perl' => 'v5.24.0', 'strict' => '0', 'warnings' => '0' } }, 'test' => { 'recommends' => { 'CPAN::Meta' => '2.120900' }, 'requires' => { 'Dancer::ModuleLoader' => '0', 'Dancer::Test' => '0', 'ExtUtils::MakeMaker' => '0', 'File::Spec' => '0', 'HTTP::Headers' => '0', 'IO::Handle' => '0', 'IPC::Open3' => '0', 'Test2::Bundle::More' => '0', 'Test2::V0' => '0', 'Test::More' => '0' } } }; $x; }release000755001750001750 015135450223 16552 5ustar00yanickyanick000000000000Dancer-Plugin-REST-0.12/xtunused-vars.t100644001750001750 14215135450223 21330 0ustar00yanickyanick000000000000Dancer-Plugin-REST-0.12/xt/releaseuse Test::More 0.96 tests => 1; use Test::Vars; subtest 'unused vars' => sub { all_vars_ok(); }; Plugin000755001750001750 015135450223 17677 5ustar00yanickyanick000000000000Dancer-Plugin-REST-0.12/lib/DancerREST.pm100644001750001750 1340415135450223 21174 0ustar00yanickyanick000000000000Dancer-Plugin-REST-0.12/lib/Dancer/Pluginpackage Dancer::Plugin::REST; our $AUTHORITY = 'cpan:SUKRIA'; # ABSTRACT: A plugin for writing RESTful apps with Dancer $Dancer::Plugin::REST::VERSION = '0.12'; use 5.24.0; use strict; use warnings; use Carp 'croak'; use Dancer ':syntax'; use Dancer::Plugin; use Dancer::HTTP; my $content_types = { json => 'application/json', yml => 'text/x-yaml', xml => 'application/xml', }; our $default_serializer; register prepare_serializer_for_format => sub { my $conf = plugin_setting; my $serializers = ( ($conf && exists $conf->{serializers}) ? $conf->{serializers} : { 'json' => 'JSON', 'yml' => 'YAML', 'xml' => 'XML', 'dump' => 'Dumper', } ); hook 'before' => sub { # remember what was there before $default_serializer ||= setting 'serializer'; my $format = params->{'format'} or return; my $serializer = $serializers->{$format} or return halt( Dancer::Error->new( code => 404, title => "unsupported format requested", message => "unsupported format requested: " . $format )->render ); 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; } }; my %triggers_map = ( get => \&get, update => \&put, create => \&post, delete => \&del, ); register resource => sub { croak "resource invoked without arguments" unless @_; my ($resource, %triggers) = @_; while( my( $t, $sub ) = each %triggers ) { my $method = $triggers_map{$t} or croak "action '$t' not recognized"; if ( $t eq 'create' ) { $method->( "/${resource}" => $triggers{$t} ); $method->( "/${resource}.:format" => $triggers{$t} ); } else { $method->( "/${resource}/:id$_" => $triggers{$t} ) for '.:format', ''; } } }; register send_entity => sub { # entity, status_code status($_[1] || 200); $_[0]; }; my %http_codes = Dancer::HTTP->codes->%*; for my $code (keys %http_codes) { my $helper_name = lc($http_codes{$code}); $helper_name =~ s/[^\w]+/_/gms; $helper_name = "status_${helper_name}"; register $helper_name => sub { my $entity = ($code >= 400 ) ? { error => $_[0]} : $_[0]; send_entity($entity, $code); }; } register_plugin; 1; __END__ =pod =encoding UTF-8 =head1 NAME Dancer::Plugin::REST - A plugin for writing RESTful apps with Dancer =head1 VERSION version 0.12 =head1 DESCRIPTION This plugin helps you write a RESTful webservice with Dancer. =head1 SYNOPSYS package MyWebService; use Dancer; use Dancer::Plugin::REST; prepare_serializer_for_format; get '/user/:id.:format' => sub { User->find(params->{id}); }; # curl http://mywebservice/user/42.json { "id": 42, "name": "John Foo", email: "john.foo@example.com"} # curl http://mywebservice/user/42.yml -- id: 42 name: "John Foo" email: "john.foo@example.com" =head1 KEYWORDS =head2 prepare_serializer_for_format When this pragma is used, a before filter is set by the plugin to automatically change the serializer when a format is detected in the URI. That means that each route you define with a B<:format> token will trigger a serializer definition, if the format is known. This lets you define all the REST actions you like as regular Dancer route handlers, without explicitly handling the outgoing data format. =head2 resource This keyword lets you declare a resource your application will handle. 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} }, update => sub { # update user with params->{user} }; # this defines the following routes: # GET /user/:id # GET /user/:id.:format # POST /user # POST /user.:format # DELETE /user/:id # DELETE /user/:id.:format # PUT /user/:id # PUT /user/:id.:format =head2 helpers Some helpers are available. This helper will set an appropriate HTTP status for you. =head3 status_ok status_ok({users => {...}}); Set the HTTP status to 200 =head3 status_created status_created({users => {...}}); Set the HTTP status to 201 =head3 status_accepted status_accepted({users => {...}}); Set the HTTP status to 202 =head3 status_bad_request status_bad_request("user foo can't be found"); Set the HTTP status to 400. This function as for argument a scalar that will be used under the key B. =head3 status_not_found status_not_found("users doesn't exists"); Set the HTTP status to 404. This function as for argument a scalar that will be used under the key B. =head1 LICENCE This module is released under the same terms as Perl itself. =head1 AUTHORS This module has been written by Alexis Sukrieh C<< >> and Franck Cuny. =head1 SEE ALSO L L =head1 AUTHORS =over 4 =item * Alexis Sukrieh =item * Franck Cuny =back =head1 COPYRIGHT AND LICENSE This software is copyright (c) 2026 by Alexis Sukrieh. This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself. =cut 05_serializer_and_resource.t100644001750001750 335215135450223 22500 0ustar00yanickyanick000000000000Dancer-Plugin-REST-0.12/tuse strict; use warnings; use Dancer::ModuleLoader; use Test2::Bundle::More; # Dancer::Test had a bug in version previous 1.3059_01 that prevent this test # from running correctly. my $dancer_version = eval "\$Dancer::VERSION"; $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; use Dancer::Plugin::REST; 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} ] }, create => sub { [ user => params->{user}, format => params->{format} ] }, update => sub { [ user => params->{user}, format => params->{format} ] }; } use Dancer::Test; plan tests => 4; my $r = dancer_response GET => '/user/42.json'; is $r->{content}, '["id","42","format","json"]' => "'id' and 'format' params are properly set for resource during GET"; $r = dancer_response POST => '/user.json', { params => { user => 'test' } }; is $r->{content}, '["user","test","format","json"]' => "'user' and 'format' params properly set for resource during POST"; $r = dancer_response PUT => '/user/1.json', { params => { user => 'anothertest' } }; is $r->{content}, '["user","anothertest","format","json"]' => "'user' and 'format' params properly set for resource during PUT"; $r = dancer_response DELETE => '/user/6.json'; is $r->{content}, '["id","6","format","json"]' => "'id' and 'format' params properly set for resource during DELETE"; 02_prepare_serializer_for_format.t100644001750001750 266315135450223 23704 0ustar00yanickyanick000000000000Dancer-Plugin-REST-0.12/tuse strict; use warnings; use Dancer::ModuleLoader; use Test2::Bundle::More; plan skip_all => "JSON is needed for this test" unless Dancer::ModuleLoader->load('JSON'); plan skip_all => "YAML is needed for this test" unless Dancer::ModuleLoader->load('YAML'); my $data = { foo => 42 }; my $json = JSON::encode_json($data); my $yaml = YAML::Dump($data); { package Webservice; use Dancer; use Dancer::Plugin::REST; setting environment => 'testing'; prepare_serializer_for_format; get '/' => sub { "root" }; get '/:something.:format' => sub { $data; }; } use Dancer::Test; my @tests = ( { request => [GET => '/'], content_type => 'text/html', response => 'root', }, { request => [GET => '/foo.json'], content_type => 'application/json', response => $json }, { request => [GET => '/foo.yml'], content_type => 'text/x-yaml', response => $yaml, }, { request => [GET => '/'], content_type => 'text/html', response => 'root', }, ); plan tests => scalar(@tests) * 2; for my $test ( @tests ) { my $response = dancer_response(@{ $test->{request} }); is($response->header('Content-Type'), $test->{content_type}, "headers have content_type set to ".$test->{content_type}); is( $response->{content}, $test->{response}, "\$data has been encoded" ); }