Unix and Linux Discussions Tagged with amp |
|
Thread / Thread Starter |
Last Post |
Replies |
Views |
Forum |
|
|
|
1 |
8,274 |
UNIX for Beginners Questions & Answers |
|
|
|
1 |
2,885 |
UNIX for Beginners Questions & Answers |
|
|
|
6 |
3,154 |
UNIX for Beginners Questions & Answers |
|
|
|
2 |
9,615 |
UNIX for Beginners Questions & Answers |
|
|
|
1 |
2,345 |
UNIX for Beginners Questions & Answers |
|
|
|
2 |
2,426 |
UNIX for Beginners Questions & Answers |
|
|
|
8 |
31,773 |
Solaris |
|
|
|
5 |
2,501 |
UNIX for Beginners Questions & Answers |
|
|
|
0 |
1,096 |
What is on Your Mind? |
|
|
|
33 |
28,793 |
Solaris |
|
|
|
2 |
3,518 |
Solaris |
|
|
|
2 |
3,360 |
IP Networking |
|
|
|
2 |
2,911 |
AIX |
|
|
|
0 |
1,490 |
Software Releases - RSS News |
|
|
|
2 |
7,298 |
Solaris |
|
|
|
2 |
2,017 |
UNIX for Dummies Questions & Answers |
|
|
|
1 |
2,868 |
Programming |
|
|
|
0 |
2,229 |
OS X Support RSS |
|
|
|
1 |
28,444 |
Shell Programming and Scripting |
|
|
|
0 |
1,896 |
Solaris BigAdmin RSS |
|
|
|
7 |
12,029 |
Ubuntu |
|
|
|
0 |
1,242 |
Complex Event Processing RSS News |
|
|
|
0 |
1,738 |
Cartoons for Geeks |
|
|
|
0 |
1,144 |
Software Releases - RSS News |
|
|
|
6 |
4,535 |
UNIX for Dummies Questions & Answers |
|
|
|
1 |
1,376 |
UNIX for Dummies Questions & Answers |
|
|
|
0 |
2,279 |
Cartoons for Geeks |
|
|
|
0 |
1,668 |
Complex Event Processing RSS News |
|
|
|
0 |
2,282 |
Cartoons for Geeks |
|
|
|
0 |
2,965 |
HP Server News and Podcasts RSS |
|
|
|
0 |
1,589 |
MySQL DevZone RSS |
|
|
|
5 |
6,277 |
UNIX for Advanced & Expert Users |
|
|
|
0 |
1,608 |
Complex Event Processing RSS News |
|
|
|
3 |
5,535 |
UNIX and Linux Applications |
|
|
|
6 |
9,831 |
Solaris |
|
|
|
0 |
2,200 |
Cartoons for Geeks |
|
|
|
0 |
1,705 |
Cartoons for Geeks |
|
|
|
2 |
4,781 |
OS X (Apple) |
|
|
|
3 |
2,118 |
Shell Programming and Scripting |
|
|
|
0 |
887 |
Software Releases - RSS News |
Mojo::Server(3pm) User Contributed Perl Documentation Mojo::Server(3pm)
NAME
Mojo::Server - HTTP server base class
SYNOPSIS
use Mojo::Base 'Mojo::Server';
sub run {
my $self = shift;
# Get a transaction
my $tx = $self->build_tx;
# Emit "request" event
$self->emit(request => $tx);
}
DESCRIPTION
Mojo::Server is an abstract HTTP server base class.
EVENTS
Mojo::Server can emit the following events.
"request"
$server->on(request => sub {
my ($server, $tx) = @_;
...
});
Emitted when a request is ready and needs to be handled.
$server->unsubscribe('request');
$server->on(request => sub {
my ($server, $tx) = @_;
$tx->res->code(200);
$tx->res->headers->content_type('text/plain');
$tx->res->body('Hello World!');
$tx->resume;
});
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 the value of the "MOJO_APP" environment variable or Mojo::HelloWorld.
METHODS
Mojo::Server inherits all methods from Mojo::EventEmitter and implements the following new ones.
"new"
my $server = Mojo::Server->new;
Construct a new Mojo::Server object and subscribe to "request" event with default request handling.
"build_tx"
my $tx = $server->build_tx;
Let application build a transaction.
"load_app"
my $app = $server->load_app('./myapp.pl');
Load application from script.
say Mojo::Server->new->load_app('./myapp.pl')->home;
"run"
$server->run;
Run server. Meant to be overloaded in a subclass.
SEE ALSO
Mojolicious, Mojolicious::Guides, <http://mojolicio.us>.
perl v5.14.2 2012-09-05 Mojo::Server(3pm)