NAME

App::MFILE::WWW::Resource - HTTP request/response cycle

SYNOPSIS

In PSGI file:

use Web::Machine;

Web::Machine->new(
    resource => 'App::MFILE::WWW::Resource',
)->to_app;

DESCRIPTION

This is where we override the default versions of various methods defined by Web::Machine::Resource.

METHODS

context

This method is where we store data that needs to be shared among routines in this module.

service_available

This is the first method called on every incoming request.

content_types_provided

For GET requests, this is where we add our HTML body to the HTTP response.

charsets_provided

This method causes Web::Machine to encode the response body in UTF-8.

default_charset

Really use UTF-8 all the time.

allowed_methods

Determines which HTTP methods we recognize.

uri_too_long

Is the URI too long?

known_content_type

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'.

malformed_request

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.

main_html

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.

test_html

Generate html for running unit tests