AnyEvent::Mojo - Start async Mojo servers easly
version 0.8003
use strict; use warnings; use AnyEvent; use AnyEvent::Mojo; my $port = 7865; my $server = mojo_server undef, $port, sub { my ($self, $tx) = @_; # Handle the request here, see AnyEvent::Mojo::Server for details }; # or... my $server = mojo_server { host => '127.0.0.1', port => $port, handler_cb => sub { my ($self, $tx) = @_; # Handle the request here, see AnyEvent::Mojo::Server for details }, }; # Run the loop $server->run # ... or ... AnyEvent->condvar->recv;
This is a first beta release. The interface should not change in a backwards incompatible way until version 1.0.
This module allows you to integrate Mojo applications with the AnyEvent framework. For example, you can run a web interface for a long-lived AnyEvent daemon.
The module exports the following functions:
Starts a server. Accepts three parameters:
The hostname or IP address to which the server will bind to. Use undef to bind to all interfaces.
undef
Port where the server will listen on. You can use undef to choose the default value of 3000.
A coderef. This handler will be called for each request. The first parameter is the server object, and the second is a Mojo::Transaction.
Mojo::Transaction
Alternatively you can pass a hash or hashref with all the options that will be passed along to AnyEvent::Mojo::Server constructor.
AnyEvent::Mojo::Server
Returns a AnyEvent::Mojo::Server object.
AnyEvent::Mojo::Server, Mojo, and AnyEvent.
Pedro Melo, <melo at cpan.org>
<melo at cpan.org>
In alphabetical order:
Lars Balker Rasmussen
Sebastian Riedel
Copyright 2008-2009 Pedro Melo.
This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
To install AnyEvent::Mojo, copy and paste the appropriate command in to your terminal.
cpanm
cpanm AnyEvent::Mojo
CPAN shell
perl -MCPAN -e shell install AnyEvent::Mojo
For more information on module installation, please visit the detailed CPAN module installation guide.