Home

Awesome

NAME

Web::Machine - A Perl port of Webmachine

VERSION

version 0.17

SYNOPSIS

use strict;
use warnings;

use Web::Machine;

{
    package HelloWorld::Resource;
    use strict;
    use warnings;

    use parent 'Web::Machine::Resource';

    sub content_types_provided { [{ 'text/html' => 'to_html' }] }

    sub to_html {
        q{<html>
            <head>
                <title>Hello World Resource</title>
            </head>
            <body>
                <h1>Hello World</h1>
            </body>
         </html>}
    }
}

Web::Machine->new( resource => 'HelloWorld::Resource' )->to_app;

DESCRIPTION

Web::Machine provides a RESTful web framework modeled as a state machine. You define one or more resource classes. Each resource represents a single RESTful URI end point, such as a user, an email, etc. The resource class can also be the target for POST requests to create a new user, email, etc.

Each resource is a state machine, and each request for a resource is handled by running the request through that state machine.

Web::Machine is built on top of Plack, but it handles the full request and response cycle.

See Web::Machine::Manual for more details on using Web::Machine in general, and how Web::Machine and Plack interact.

This is a port of Webmachine, actually it is much closer to the Ruby version, with a little bit of the JavaScript version and even some of the Python version thrown in for good measure.

You can learn a bit about Web::Machine's history from the slides for my 2012 YAPC::NA talk.

To learn more about Webmachine, take a look at the links in the SEE ALSO section.

METHODS

NOTE: This module is a Plack::Component subclass and so follows the interface set forward by that module.

DEBUGGING

If you set the WM_DEBUG environment variable to 1 we will print out information about the path taken through the state machine to STDERR.

If you set WM_DEBUG to diag then debugging information will be printed using Test::More's diag() sub instead.

SEE ALSO

SUPPORT

bugs may be submitted through https://github.com/houseabsolute/webmachine-perl/issues.

AUTHORS

CONTRIBUTORS

COPYRIGHT AND LICENCE

This software is copyright (c) 2016 by Infinity Interactive, Inc.

This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.