Apache2-Translation
view release on metacpan or search on metacpan
lib/Apache2/Translation.pod view on Meta::CPAN
=head1 NAME
Apache2::Translation - Configuring Apache dynamically
=head1 SYNOPSIS
LoadModule perl_module /path/to/mod_perl.so
PerlLoadModule Apache2::Translation
PerlTransHandler Apache2::Translation
PerlMapToStorageHandler Apache2::Translation
TranslationEvalCache 1000
TranslationKey MyKey
<TranslationProvider DB>
Database dbi:mysql:dbname:host
User username
Password password
Singleton 1
Table tablename
Key keycolumn
Uri uricolumn
Block blockcolumn
Order ordercolumn
Action actioncolumn
Cachetbl cachetablename
Cachecol cachecolumn
Cachesize 1000
</TranslationProvider>
# another provider
<TranslationProvider File>
Configfile /path/to/config
</TranslationProvider>
# export our provider parameters
<Location /config>
SetHandler modperl
PerlResponseHandler Apache2::Translation::Config
</Location>
# configuring the WEB interface
PerlModule Apache2::Translation::Admin
<Location /-/transadm/>
SetHandler modperl
PerlResponseHandler Apache2::Translation::Admin
</Location>
=head1 DESCRIPTION
As the name implies C<Apache2::Translation> lives mostly in the URI Translation
Phase. It is somehow similar to C<mod_rewrite> but configuration
statements are read at runtime, thus, allowing to reconfigure
a server without restarting it.
The actual configuration statements are read by means of a
I<Translation Provider>, a Perl class offering
a particular interface, see below. Currently there are 3 providers
implemented, L<Apache2::Translation::DB>, L<Apache2::Translation::BDB>,
and L<Apache2::Translation::File>.
There is also a WEB interface (L<Apache2::Translation::Admin>).
=head2 B<An Example>
Let's begin with an example. Given some database table:
id key uri blk ord action
1 front :PRE: 0 0 Cond: $HOSTNAME !~ /^(?:www\.)xyz\.(?:com|de)$/
2 front :PRE: 0 1 Redirect: 'http://xyz.com'.$URI, 301
3 front :PRE: 1 0 Do: $CTX{lang}='en'
4 front :PRE: 1 1 Cond: $HOSTNAME =~ /de$/
5 front :PRE: 1 2 Do: $CTX{lang}='de'
6 front /static 0 0 File: $DOCROOT.'/'.$CTX{lang}.$MATCHED_PATH_INFO
7 front /appl1 0 0 Proxy: 'http://backend/'.$CTX{lang}.$URI
8 front /appl2 0 0 Proxy: 'http://backend/'.$URI.'?l='.$CTX{lang}
9 front / 0 0 Config: ['AuthName "secret"'], ['AuthType Basic']
10 back :PRE: 0 0 Cond: $r->connection->remote_ip ne '127.0.0.1'
( run in 1.823 second using v1.01-cache-2.11-cpan-5837b0d9d2c )