Mojo::Server - HTTP Server Base Class
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); }
Mojo::Server is an abstract HTTP server base class.
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.
100 Continue
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.
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.
Mojolicious, Mojolicious::Guides, http://mojolicious.org.
To install Mojolicious, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Mojolicious
CPAN shell
perl -MCPAN -e shell install Mojolicious
For more information on module installation, please visit the detailed CPAN module installation guide.