Sloth::Method - The implementation of a single HTTP method on a resource
A Map[ContentType = Sloth::RequestParser].
This map defines a list of parsers that are able to parse the body of a HTTP request into a meaningful, but more importantly, common, set of input parameters.
If this is left undefined it is assumed that a body is not meant to be provided to the method, and that all necessary parameters can be derived from the URI query parameters and path parts.
A Data::TreeValidator validator.
This takes the input from query parameters, path parts, and possibly the parsed request body, and validates it. It can optionally transform the data, and will finally return a set of clean input parameters which are passed to "execute".
$self->process_request($request : Sloth::Request)
Process a Sloth::Request and possibly return a resource.
You usually won't need to override this method, as by default it does the boiler plate plumbing for you (checking the Accept header, trying to parse the body, etc). Most users will simply need to implement "execute".
Required. Classes which consume this role must implement this method.
Executes the implemented HTTP method (for example a GET or DELETE operation) and optionally returns a resource to represent back to the user. Takes an object that represents the cleaned input parameters - a combination of path arguments, query paramaters and the parsed body (if there was one).
If you are returning a custom Sloth::Response from your method body, you may still wish to serialize some data into the response body. By using try_serialize you will get correct handling of the Accept: header from the client.
This software is copyright (c) 2011 by Oliver Charles <firstname.lastname@example.org>.
This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.
To install Sloth, copy and paste the appropriate command in to your terminal.
perl -MCPAN -e shell
For more information on module installation, please visit the detailed CPAN module installation guide.