Tree @HEAD (Download .tar.gz)
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 | NAME Dancer::Plugin::REST - A plugin for writing RESTful apps with Dancer VERSION version 0.11 DESCRIPTION This plugin helps you write a RESTful webservice with Dancer. 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" 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. 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 status_ok({users => {...}}); Set the HTTP status to 200 status_created status_created({users => {...}}); Set the HTTP status to 201 status_accepted status_accepted({users => {...}}); Set the HTTP status to 202 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 error. 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 error. LICENCE This module is released under the same terms as Perl itself. AUTHORS This module has been written by Alexis Sukrieh "<sukria@sukria.net>" and Franck Cuny. SEE ALSO Dancer <http://en.wikipedia.org/wiki/Representational_State_Transfer> AUTHORS * Alexis Sukrieh <sukria@sukria.net> * Franck Cuny <franckc@cpan.org> COPYRIGHT AND LICENSE This software is copyright (c) 2010 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. |
Commit History @HEAD
- debian/*: update GitHub URLs to use HTTPS. gregor herrmann 5 years ago
- update changelog gregor herrmann 5 years ago
- debian/*: update URLs from {search,www}.cpan.org to MetaCPAN. gregor herrmann 5 years ago
- Update Vcs-* headers for switch to salsa.debian.org Salvatore Bonaccorso 6 years ago
- update changelog Salvatore Bonaccorso 6 years ago
- Update Vcs-* headers for switch to salsa.debian.org Salvatore Bonaccorso 6 years ago
- Mention DUCK in the changelog entry Axel Beckert 8 years ago
- Change broken search.cpan.org Homepage header to a metacpan.org based one Axel Beckert 8 years ago
- update changelog Salvatore Bonaccorso 9 years ago
- Update Vcs-Browser URL to cgit web frontend Salvatore Bonaccorso 9 years ago
- Prepare for release: Update changelog and control file. Jonas Smedegaard 9 years ago
- Build-depend on libxml-simple-perl: Improves testsuite. Jonas Smedegaard 9 years ago
- Update copyright info: Add alternate git source URL. Jonas Smedegaard 9 years ago
- Relax to build-depend unversioned on libmodule-build-perl: Needed version satisfied even in oldstable. Jonas Smedegaard 9 years ago
- Prepare for release: Update changelog, control file and copyright hints. Jonas Smedegaard 9 years ago
- Sync control.in with control: Fix use canonical anonscm.debian.org host in Vcs-Git URL. Jonas Smedegaard 9 years ago
- Tidy rules file: Restructure package relations resolving. Jonas Smedegaard 9 years ago
- Update copyright info: Extend packaging to cover recent years, and bump its licensing to GPL-3+. Quote license names. Jonas Smedegaard 9 years ago
- Bump debhelper compatibility to 8: Corresponding version satisfied even in oldstable. Jonas Smedegaard 9 years ago
- Update watch file to use metacpan.org and cpan.org/authors (not search.cpan.org) URLs. Jonas Smedegaard 9 years ago
- Update get-orig-source hint to match change of upstream source. Jonas Smedegaard 9 years ago
- Update copyright file: Fix use comment and license pseudo-sections to obey silly restrictions of copyright format 1.0. Jonas Smedegaard 9 years ago
- Revert wrong fix for lintian warning. Jonas Smedegaard 9 years ago
- prepare changelog for release Florian Schlichting 10 years ago
- Update Vcs-* fields to their canonical value Florian Schlichting 10 years ago
- switch cdbs to perl-build.mk Florian Schlichting 10 years ago
- Declare compliance with Debian Policy 3.9.5 Florian Schlichting 10 years ago
- Ship CONTRIBUTORS as docs Florian Schlichting 10 years ago
- Make Dancer dependency versioned, and specify M::B minimum version Florian Schlichting 10 years ago
- Add year to upstream copyright Florian Schlichting 10 years ago