1Catalyst::Action::REST(U3s)er Contributed Perl DocumentatCiaotnalyst::Action::REST(3)
2
3
4

NAME

6       Catalyst::Action::REST - Automated REST Method Dispatching
7

SYNOPSIS

9           sub foo :Local :ActionClass('REST') {
10             ... do setup for HTTP method specific handlers ...
11           }
12
13           sub foo_GET {
14             ... do something for GET requests ...
15           }
16
17           # alternatively use an Action
18           sub foo_PUT : Action {
19             ... do something for PUT requests ...
20           }
21

DESCRIPTION

23       This Action handles doing automatic method dispatching for REST
24       requests.  It takes a normal Catalyst action, and changes the dispatch
25       to append an underscore and method name.  First it will try dispatching
26       to an action with the generated name, and failing that it will try to
27       dispatch to a regular method.
28
29       For example, in the synopsis above, calling GET on "/foo" would result
30       in the foo_GET method being dispatched.
31
32       If a method is requested that is not implemented, this action will
33       return a status 405 (Method Not Found).  It will populate the "Allow"
34       header with the list of implemented request methods.  You can override
35       this behavior by implementing a custom 405 handler like so:
36
37          sub foo_not_implemented {
38             ... handle not implemented methods ...
39          }
40
41       If you do not provide an _OPTIONS subroutine, we will automatically
42       respond with a 200 OK.  The "Allow" header will be populated with the
43       list of implemented request methods.
44
45       It is likely that you really want to look at
46       Catalyst::Controller::REST, which brings this class together with
47       automatic Serialization of requests and responses.
48
49       When you use this module, it adds the Catalyst::TraitFor::Request::REST
50       role to your request class.
51

METHODS

53       dispatch
54           This method overrides the default dispatch mechanism to the re-
55           dispatching mechanism described above.
56

SEE ALSO

58       You likely want to look at Catalyst::Controller::REST, which implements
59       a sensible set of defaults for a controller doing REST.
60
61       This class automatically adds the Catalyst::TraitFor::Request::REST
62       role to your request class.  If you're writing a webapp which provides
63       RESTful responses and still needs to accommodate web browsers, you may
64       prefer to use Catalyst::TraitFor::Request::REST::ForBrowsers instead.
65
66       Catalyst::Action::Serialize, Catalyst::Action::Deserialize
67

TROUBLESHOOTING

69       Q: I'm getting a "415 Unsupported Media Type" error. What gives?!
70           A:  Most likely, you haven't set Content-type equal to
71           "application/json", or one of the accepted return formats.  You can
72           do this by setting it in your query accepted return formats.  You
73           can do this by setting it in your query string thusly:
74           "?content-type=application%2Fjson (where %2F == / uri escaped)."
75
76           NOTE Apache will refuse %2F unless configured otherwise.  Make sure
77           "AllowEncodedSlashes On" is in your httpd.conf file in order for
78           this to run smoothly.
79

AUTHOR

81       Adam Jacob <adam@stalecoffee.org>, with lots of help from mst and
82       jrockway
83
84       Marchex, Inc. paid me while I developed this module.
85       (<http://www.marchex.com>)
86

CONTRIBUTORS

88       Tomas Doran (t0m) <bobtfish@bobtfish.net>
89
90       John Goulah
91
92       Christopher Laco
93
94       Daisuke Maki <daisuke@endeworks.jp>
95
96       Hans Dieter Pearcey
97
98       Dave Rolsky <autarch@urth.org>
99
100       Luke Saunders
101
102       Arthur Axel "fREW" Schmidt <frioux@gmail.com>
103
104       J. Shirley <jshirley@gmail.com>
105
107       Copyright the above named AUTHOR and CONTRIBUTORS
108

LICENSE

110       You may distribute this code under the same terms as Perl itself.
111
112
113
114perl v5.12.1                      2010-09-01         Catalyst::Action::REST(3)
Impressum