Unix and Linux Discussions Tagged with amp |
|
Thread / Thread Starter |
Last Post |
Replies |
Views |
Forum |
|
|
|
1 |
8,418 |
UNIX for Beginners Questions & Answers |
|
|
|
1 |
2,926 |
UNIX for Beginners Questions & Answers |
|
|
|
6 |
3,207 |
UNIX for Beginners Questions & Answers |
|
|
|
2 |
9,649 |
UNIX for Beginners Questions & Answers |
|
|
|
1 |
2,406 |
UNIX for Beginners Questions & Answers |
|
|
|
2 |
2,479 |
UNIX for Beginners Questions & Answers |
|
|
|
8 |
32,077 |
Solaris |
|
|
|
5 |
2,519 |
UNIX for Beginners Questions & Answers |
|
|
|
0 |
1,106 |
What is on Your Mind? |
|
|
|
33 |
29,275 |
Solaris |
|
|
|
2 |
3,524 |
Solaris |
|
|
|
2 |
3,369 |
IP Networking |
|
|
|
2 |
2,917 |
AIX |
|
|
|
0 |
1,497 |
Software Releases - RSS News |
|
|
|
2 |
7,303 |
Solaris |
|
|
|
2 |
2,024 |
UNIX for Dummies Questions & Answers |
|
|
|
1 |
2,879 |
Programming |
|
|
|
0 |
2,243 |
OS X Support RSS |
|
|
|
1 |
28,451 |
Shell Programming and Scripting |
|
|
|
0 |
1,902 |
Solaris BigAdmin RSS |
|
|
|
7 |
12,041 |
Ubuntu |
|
|
|
0 |
1,244 |
Complex Event Processing RSS News |
|
|
|
0 |
1,746 |
Cartoons for Geeks |
|
|
|
0 |
1,150 |
Software Releases - RSS News |
|
|
|
6 |
4,540 |
UNIX for Dummies Questions & Answers |
|
|
|
1 |
1,379 |
UNIX for Dummies Questions & Answers |
|
|
|
0 |
2,286 |
Cartoons for Geeks |
|
|
|
0 |
1,672 |
Complex Event Processing RSS News |
|
|
|
0 |
2,285 |
Cartoons for Geeks |
|
|
|
0 |
2,973 |
HP Server News and Podcasts RSS |
|
|
|
0 |
1,592 |
MySQL DevZone RSS |
|
|
|
5 |
6,286 |
UNIX for Advanced & Expert Users |
|
|
|
0 |
1,614 |
Complex Event Processing RSS News |
|
|
|
3 |
5,550 |
UNIX and Linux Applications |
|
|
|
6 |
9,840 |
Solaris |
|
|
|
0 |
2,203 |
Cartoons for Geeks |
|
|
|
0 |
1,708 |
Cartoons for Geeks |
|
|
|
2 |
4,797 |
OS X (Apple) |
|
|
|
3 |
2,125 |
Shell Programming and Scripting |
|
|
|
0 |
895 |
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)