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);
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.
build_tx_cb
my $btx = $server->build_tx_cb;
$server = $server->build_tx_cb(sub {
my $self = shift;
return Mojo::Transaction::HTTP->new;
});
Transaction builder callback.
continue_handler_cb
my $handler = $server->continue_handler_cb;
$server = $server->continue_handler_cb(sub {
my ($self, $tx) = @_;
});
Callback handling 100 Continue
requests.
handler_cb
my $handler = $server->handler_cb;
$server = $server->handler_cb(sub {
my ($self, $tx) = @_;
});
Handler callback.
reload
my $reload = $server->reload;
$server = $server->reload(1);
Activate automatic reloading.
websocket_handshake_cb
my $handshake = $server->websocket_handshake_cb;
$server = $server->websocket_handshake_cb(sub {
my ($self, $tx) = @_;
});
WebSocket handshake callback.
METHODS
Mojo::Server inherits all methods from Mojo::Base and implements the following new ones.
new
my $server = Mojo::Server->new;
Construct a new Mojo::Server object.
run
$server->run;
Start server.