Boris Sukholitko > Apache-SWIT-0.54 > Apache::SWIT

Download:
Apache-SWIT-0.54.tar.gz

Dependencies

Annotate this POD

CPAN RT

New  3
Open  0
View/Report Bugs
Module Version: 0.54   Source  

NAME ^

Apache::SWIT - mod_perl based application server with integrated testing.

SYNOPSIS ^

        package MyHandler;
        use base 'Apache::SWIT';

        # overload render routine
        sub swit_render {
                my ($class, $r) = @_;
                return ({ hello => 'world' }, 'my_template.tt');
                # or return { hello => 'world' }; to rely on swit.yaml
                # based generation
        }

        # overload update routine, usually result of POST
        sub swit_update {
                my ($class, $r) = @_;
                # do some work ...
                # and redirect to another page
                return '/redirect/to/some/url';
        }

DISCLAIMER ^

This is pre-alpha quality software. Please use it on your own risk.

DESCRIPTION ^

This module serves as yet another mod_perl based application server.

It tries to capture several often occuring paradigms in mod_perl development. It provides user with the tools to bootstrap a new project, write tests easily, etc.

METHODS ^

$class->swit_send_http_header($r, $ct)

Sends HTTP default headers: session cookie and content type. $r is apache request and $ct is optional content type (defaults to text/html; charset=utf-8.

$class->swit_die($msg, $r, @data_to_dump)

Dies with first line of $msg using Carp::croak and dumps request $r and @data_to_dump with Data::Dumper into /tmp/swit_<time>.err file.

swit_post_max

Maximal size of POST request. Default is 1M. Overload it to return something else.

$class->swit_update_handler($class, $r)

Entry point for an update handler. Calls $class->swit_update($apr) function with Apache2::Request parameter. The result of swit_update henceforth is called $to is passed down.

If $to is regular string then 302 status is produced with Location equal to $to.

If $to is array reference and first item is a number then the status with $to-[0]> is produced and $to->[1] is returned as response body. $to->[2] may by used as content type.

I.e. [ 200, "Hello", "text/plain" ] will respond with 200 OK status and Hello as a body with text/plain as content type.

The first item can also be INTERNAL magic string. In that case internal redirect to the second array item is produced.

Of $to parameters only $to->[0] is mandatory.

BUGS ^

Much needed documentation is non-existant at the moment.

AUTHOR ^

        Boris Sukholitko
        boriss@gmail.com

COPYRIGHT ^

This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.

The full text of the license can be found in the LICENSE file included with this module.

SEE ALSO ^

HTML::Tested

syntax highlighting: