The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.

NAME

Mojo - The Box!

SYNOPSIS

    use base 'Mojo';

    # All the complexities of CGI, FastCGI, PSGI, HTTP and WebSocket get
    # reduced to a single method call!
    sub handler {
        my ($self, $tx) = @_;

        # Request
        my $method = $tx->req->method;
        my $path   = $tx->req->url->path;

        # Response
        $tx->res->headers->content_type('text/plain');
        $tx->res->body("$method request for $path!");
    }

DESCRIPTION

Mojo provides a flexible runtime environment for Perl web frameworks. It provides all the basic tools and helpers needed to write simple web applications and higher level web frameworks such as Mojolicious.

See Mojolicious for more!

ATTRIBUTES

Mojo implements the following attributes.

build_tx_cb

    my $cb = $mojo->build_tx_cb;
    $mojo  = $mojo->build_tx_cb(sub { ... });

The transaction builder callback, by default it builds a Mojo::Transaction::HTTP object.

client

    my $client = $mojo->client;
    $mojo      = $mojo->client(Mojo::Client->new);

A full featured HTTP 1.1 client for use in your applications, by default a Mojo::Client object.

home

    my $home = $mojo->home;
    $mojo    = $mojo->home(Mojo::Home->new);

The home directory of your application, by default a Mojo::Home object which stringifies to the actual path.

log

    my $log = $mojo->log;
    $mojo   = $mojo->log(Mojo::Log->new);
    

The logging layer of your application, by default a Mojo::Log object.

websocket_handshake_cb

    my $cb = $mojo->websocket_handshake_cb;
    $mojo  = $mojo->websocket_handshake_cb(sub { ... });

The websocket handshake callback, by default it builds a Mojo::Transaction::WebSocket object and handles the response for the handshake request.

METHODS

Mojo inherits all methods from Mojo::Base and implements the following new ones.

new

    my $mojo = Mojo->new;

Construct a new Mojo application. Will automatically detect your home directory and set up logging to log/mojo.log if there's a log directory.

handler

    $tx = $mojo->handler($tx);

The handler is the main entry point to your application or framework and will be called for each new transaction.

    sub handler {
        my ($self, $tx) = @_;
    }

start

    Mojo->start;
    Mojo->start('daemon');

Start the Mojo::Commands command line interface for your application.

SEE ALSO

Mojolicious, Mojolicious::Book, http://mojolicious.org.