When inserting Cat::Req::REST, always add trait, rather than sometimes using the...
[catagits/Catalyst-Action-REST.git] / README
CommitLineData
01f9819a 1NAME
63d41fcd 2 Catalyst::Action::REST - Automated REST Method Dispatching
84e2464c 3
01f9819a 4SYNOPSIS
63d41fcd 5 sub foo :Local :ActionClass('REST') {
6 ... do setup for HTTP method specific handlers ...
7 }
01f9819a 8
63d41fcd 9 sub foo_GET {
10 ... do something for GET requests ...
01f9819a 11 }
12
63d41fcd 13 # alternatively use an Action
14 sub foo_PUT : Action {
15 ... do something for PUT requests ...
01f9819a 16 }
17
18DESCRIPTION
63d41fcd 19 This Action handles doing automatic method dispatching for REST
20 requests. It takes a normal Catalyst action, and changes the dispatch to
21 append an underscore and method name. First it will try dispatching to
22 an action with the generated name, and failing that it will try to
23 dispatch to a regular method.
01f9819a 24
63d41fcd 25 For example, in the synopsis above, calling GET on "/foo" would result
26 in the foo_GET method being dispatched.
8f00a41b 27
63d41fcd 28 If a method is requested that is not implemented, this action will
29 return a status 405 (Method Not Found). It will populate the "Allow"
30 header with the list of implemented request methods. You can override
31 this behavior by implementing a custom 405 handler like so:
8f00a41b 32
63d41fcd 33 sub foo_not_implemented {
34 ... handle not implemented methods ...
35 }
8f00a41b 36
63d41fcd 37 If you do not provide an _OPTIONS subroutine, we will automatically
38 respond with a 200 OK. The "Allow" header will be populated with the
39 list of implemented request methods.
fec618b0 40
63d41fcd 41 It is likely that you really want to look at Catalyst::Controller::REST,
42 which brings this class together with automatic Serialization of
43 requests and responses.
fec618b0 44
63d41fcd 45 When you use this module, the request class will be changed to
46 Catalyst::Request::REST.
8f00a41b 47
63d41fcd 48METHODS
49 dispatch
50 This method overrides the default dispatch mechanism to the
51 re-dispatching mechanism described above.
8f00a41b 52
63d41fcd 53SEE ALSO
54 You likely want to look at Catalyst::Controller::REST, which implements
55 a sensible set of defaults for a controller doing REST.
8f00a41b 56
63d41fcd 57 Catalyst::Action::Serialize, Catalyst::Action::Deserialize
8f00a41b 58
63d41fcd 59TROUBLESHOOTING
60 Q: I'm getting a "415 Unsupported Media Type" error. What gives?!
61 A: Most likely, you haven't set Content-type equal to
62 "application/json", or one of the accepted return formats. You can
63 do this by setting it in your query accepted return formats. You can
64 do this by setting it in your query string thusly:
65 "?content-type=application%2Fjson (where %2F == / uri escaped)."
8f00a41b 66
63d41fcd 67 NOTE Apache will refuse %2F unless configured otherwise. Make sure
68 "AllowEncodedSlashes On" is in your httpd.conf file in order for
69 this to run smoothly.
8f00a41b 70
63d41fcd 71AUTHOR
72 Adam Jacob <adam@stalecoffee.org>, with lots of help from mst and
73 jrockway
8f00a41b 74
63d41fcd 75 Marchex, Inc. paid me while I developed this module.
76 (<http://www.marchex.com>)
8f00a41b 77
63d41fcd 78CONTRIBUTORS
79 Arthur Axel "fREW" Schmidt <frioux@gmail.com>
8f00a41b 80
63d41fcd 81 Christopher Laco
8f00a41b 82
63d41fcd 83 Luke Saunders
01f9819a 84
63d41fcd 85 John Goulah
01f9819a 86
63d41fcd 87 Daisuke Maki <daisuke@endeworks.jp>
01f9819a 88
63d41fcd 89 J. Shirley <jshirley@gmail.com>
01f9819a 90
63d41fcd 91 Hans Dieter Pearcey
01f9819a 92
63d41fcd 93 Tomas Doran (t0m) <bobtfish@bobtfish.net>
01f9819a 94
63d41fcd 95COPYRIGHT
96 Copyright the above named AUTHOR and CONTRIBUTORS
01f9819a 97
98LICENSE
63d41fcd 99 You may distribute this code under the same terms as Perl itself.
01f9819a 100