NAME

AnyEvent::Mojo - Start async Mojo servers easly

VERSION

version 0.8003

SYNOPSIS

    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;

STATUS

This is a first beta release. The interface should not change in a backwards incompatible way until version 1.0.

DESCRIPTION

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.

FUNCTIONS

The module exports the following functions:

mojo_server

Starts a server. Accepts three parameters:

host

The hostname or IP address to which the server will bind to. Use undef to bind to all interfaces.

port

Port where the server will listen on. You can use undef to choose the default value of 3000.

cb

A coderef. This handler will be called for each request. The first parameter is the server object, and the second is a Mojo::Transaction.

Alternatively you can pass a hash or hashref with all the options that will be passed along to AnyEvent::Mojo::Server constructor.

Returns a AnyEvent::Mojo::Server object.

SEE ALSO

AnyEvent::Mojo::Server, Mojo, and AnyEvent.

AUTHOR

Pedro Melo, <melo at cpan.org>

CREDITS

In alphabetical order:

Lars Balker Rasmussen

Sebastian Riedel

COPYRIGHT & LICENSE

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.