NAME

Continuity - Abstract away statelessness of HTTP using continuations, for stateful Web applications

SYNOPSIS

#!/usr/bin/perl
use strict;
use warnings;
use Coro;
use Coro::Event;

use Continuity;
my $server = new Continuity;

sub main {
  my $request = shift;
  $request = $request->next();
  # must do a substr to chop the leading '/'
  my $name = substr($request->{request}->url->path, 1) || 'World';
  $request->print("Hello, $name!");
  $request = $request->next();
  $name = substr($request->{request}->url->path, 1) || 'World';
  $request->print("Hello to you too, $name!");
}

Event::loop();

DESCRIPTION

Continuity is a library (not a framework) to simplify Web applications. Each session is written and runs as if it were a persistant application, and is able to request additional input at any time without exiting. Applications call a method, $request-next>, which temporarily gives up control of the CPU and then (eventually) returns the next request. Put another way, coroutines make the HTTP Web appear stateful.

Beyond the basic idea of using coroutines to build Web apps, some logic is required to decide how to associate incoming requests with coroutines, and logic is required to glue the daemonized application server to the Web. Sample implementations of both are provided (specifically, an adapter to run a dedicated Webserver built out of HTTP::Request is included), and these implementations are useful for many situations and are subclassable.

This is ALPHA software, and feedback/code is welcomed. See the Wiki in the references below for things the authors are unhappy with.

METHODS

$server = Continuity->new(...)

The Continuity object wires together an adapter and a mapper. Creating the Continuity object gives you the defaults wired together, or if user-supplied instances are provided, it wires those together.

Arguments:

adapter -- defaults to an instance of Continuity::Adapt::HttpDaemon
mapper -- defaults to an instance of Continuity::Mapper
docroot -- defaults to .
callback -- defaults to \&::main
staticp -- defaults to sub { 0 }, used to indicate whether any request is for static content
debug -- defaults to 4 at the moment ;)

SEE ALSO

Website/Wiki: http://continuity.tlt42.org/

Continuity::Adapt::HttpDaemon, Continuity::Mapper, Continuity::Request, Coro.

AUTHOR

Brock Wilcox <awwaiid@thelackthereof.org> - http://thelackthereof.org/
Scott Walkters <scott@slowass.net> - http://slowass.net/

COPYRIGHT

Copyright (c) 2004-2006 Brock Wilcox <awwaiid@thelackthereof.org>. All
rights reserved.  This program is free software; you can redistribute it
and/or modify it under the same terms as Perl itself.