Apache2-Translation

 view release on metacpan or  search on metacpan

README  view on Meta::CPAN

NAME
    Apache2::Translation - Configuring Apache dynamically

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>

INSTALLATION
     perl Makefile.PL
     make
     make test
     make install

DESCRIPTION
    As the name implies "Apache2::Translation" lives mostly in the URI
    Translation Phase. It is somehow similar to "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 *Translation
    Provider*, a Perl class offering a particular interface, see below.
    Currently there are 3 providers implemented, Apache2::Translation::DB,
    Apache2::Translation::BDB, and Apache2::Translation::File.

    There is also a WEB interface (Apache2::Translation::Admin).

  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



( run in 0.801 second using v1.01-cache-2.11-cpan-5837b0d9d2c )