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. If you do not provide an _HEAD
44       either, we will auto dispatch to the _GET one in case it exists.
45
46       It is likely that you really want to look at
47       Catalyst::Controller::REST, which brings this class together with
48       automatic Serialization of requests and responses.
49
50       When you use this module, it adds the Catalyst::TraitFor::Request::REST
51       role to your request class.
52

METHODS

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

SEE ALSO

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

TROUBLESHOOTING

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

AUTHOR

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

CONTRIBUTORS

90       Tomas Doran (t0m) <bobtfish@bobtfish.net>
91
92       John Goulah
93
94       Christopher Laco
95
96       Daisuke Maki <daisuke@endeworks.jp>
97
98       Hans Dieter Pearcey
99
100       Brian Phillips <bphillips@cpan.org>
101
102       Dave Rolsky <autarch@urth.org>
103
104       Luke Saunders
105
106       Arthur Axel "fREW" Schmidt <frioux@gmail.com>
107
108       J. Shirley <jshirley@gmail.com>
109
110       Gavin Henry <ghenry@surevoip.co.uk>
111
112       Gerv http://www.gerv.net/
113
114       Colin Newell <colin@opusvl.com>
115
116       Wallace Reis <wreis@cpan.org>
117
118       André Walker (andrewalker) <andre@cpan.org>
119
121       Copyright (c) 2006-2015 the above named AUTHOR and CONTRIBUTORS
122

LICENSE

124       You may distribute this code under the same terms as Perl itself.
125
126
127
128perl v5.34.0                      2021-07-22         Catalyst::Action::REST(3)
Impressum