Apache2-Controller
view release on metacpan or search on metacpan
lib/Apache2/Controller.pm view on Meta::CPAN
package Apache2::Controller;
=encoding utf8
=head1 NAME
Apache2::Controller - fast MVC-style Apache2 handler apps
=head1 VERSION
Version 1.001.001
=cut
use version;
our $VERSION = version->new('1.001.001');
=head1 INSTALLATION PRE-REQUISITES
You need mod_perl2, L<Apache::Test> and L<version> installed to
build this distribution with CPAN.
Otherwise the Makefile.PL will not run
to tell you that prerequisites failed.
This is a drawback of using L<Apache::Test>.
=head1 SYNOPSIS
The handler IS the controller. A2C gets all the
abstractions out from between your controller logic and
the Apache2 methods to control input/output, status etc.
You control Apache2 directly, or use a rendering base like
L<Apache2::Controller::Render::Template> which gives a method
to render using L<Template> Toolkit.
For Apache2 config file setup see L<Apache2::Controller::Dispatch>,
which sets a PerlResponseHandler of Apache::Controller, which
then creates your controller object and calls the chosen
method for the uri.
package MyApp::C::Foo;
use strict;
use warnings FATAL => 'all';
# base Apache2::Request is optional, it would limit your
# choice of method names. request object is in $self->{r}
# if you do not choose to use it to get access to the
# Apache2 methods via $self.
use base qw(
Apache2::Controller
Apache2::Request
);
use Apache2::Const -compile => qw( :http );
sub allowed_methods {qw( default bar baz )}
# suppose '/foo' is the uri path dispatched to this controller
# and your dispatch uses Apache2::Controller::Dispatch::Simple
# http://myapp.xyz/foo/
sub default {
my ($self) = @_;
$self->content_type('text/plain');
( run in 0.766 second using v1.01-cache-2.11-cpan-e1769b4cff6 )