App::MFILE::WWW::Resource - HTTP request/response cycle
In PSGI file:
use Web::Machine; Web::Machine->new( resource => 'App::MFILE::WWW::Resource', )->to_app;
This is where we override the default versions of various methods defined by Web::Machine::Resource.
This method is where we store data that needs to be shared among routines in this module.
This is the first method called on every incoming request.
For GET requests, this is where we add our HTML body to the HTTP response.
This method causes Web::Machine to encode the response body in UTF-8.
Really use UTF-8 all the time.
Determines which HTTP methods we recognize.
Is the URI too long?
Looks at the 'Content-Type' header of POST requests, and generates a "415 Unsupported Media Type" response if it is anything other than 'application/json'.
This test examines the request body. It can either be empty or contain valid JSON; otherwise, a '400 Malformed Request' response is returned. If it contains valid JSON, it is converted into a Perl hashref and stored in the 'request_body' attribute of the context.
Takes the session object and returns HTML string to be displayed in the user's browser.
FIXME: might be worth spinning this off into a separate module.
Generate html for running unit tests
To install App::MFILE::WWW, copy and paste the appropriate command in to your terminal.
cpanm
cpanm App::MFILE::WWW
CPAN shell
perl -MCPAN -e shell install App::MFILE::WWW
For more information on module installation, please visit the detailed CPAN module installation guide.