NAME

Mojo::Server - HTTP Server Base Class

SYNOPSIS

use base 'Mojo::Server';

sub run {
    my $self = shift;

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

    # Call the handler
    $tx = $self->handler_cb->($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);

app_class

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

build_tx_cb

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

continue_handler_cb

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

handler_cb

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

reload

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

websocket_handshake_cb

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

METHODS

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

new

my $server = Mojo::Server->new;

run

$server->run;

SEE ALSO

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