NAME

Mojo::Server - HTTP Server Base Class

SYNOPSIS

use base 'Mojo::Server';

sub run {
    my $self = shift;

    # Get a transaction
    my $tx = $self->on_build_tx->($self);

    # Call the handler
    $tx = $self->on_handler->($self);
}

DESCRIPTION

Mojo::Server is an abstract HTTP server base class.

ATTRIBUTES

Mojo::Server implements the following attributes.

app

my $app = $server->app;
$server = $server->app(MojoSubclass->new);

Application this server handles, defaults to a Mojo::HelloWorld object.

app_class

my $app_class = $server->app_class;
$server       = $server->app_class('MojoSubclass');

Class of the application this server handles, defaults to Mojo::HelloWorld.

on_build_tx

my $btx = $server->on_build_tx;
$server = $server->on_build_tx(sub {
    my $self = shift;
    return Mojo::Transaction::HTTP->new;
});

Transaction builder callback.

on_handler

my $handler = $server->on_handler;
$server     = $server->on_handler(sub {
    my ($self, $tx) = @_;
});

Handler callback.

on_websocket

my $handshake = $server->on_websocket;
$server       = $server->on_websocket(sub {
    my ($self, $tx) = @_;
});

WebSocket handshake callback.

reload

my $reload = $server->reload;
$server    = $server->reload(1);

Activate automatic reloading.

METHODS

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

run

$server->run;

Start server.

SEE ALSO

Mojolicious, Mojolicious::Guides, http://mojolicio.us.