John Beppu > Squatting-0.81 > Squatting::With::PerHostConfig

Download:
Squatting-0.81.tar.gz

Dependencies

Annotate this POD

CPAN RT

Open  0
View/Report Bugs
Source  

NAME ^

Squatting::With::PerHostConfig - vary %CONFIG based on $c->env->{HTTP_HOST}

SYNOPSIS ^

First, define a lookup_config_for_host method.

  use Rhetoric 'With::PerHostConfig';
  {
    package Rhetoric;
    our %HOST_CONFIG = (
      'localhost' => {
        theme => 'default',
      },
      'test1.local' => {
        theme => 'scary',
      },
      m.local => {
        theme => 'mobile',
      },
    );

    # How you choose to implement this method is completely up to you.
    # Feel free to pull data from a database if you so desire.

    sub lookup_config_for_host {
      my ($class, $host) = @_;
      return $HOST_CONFIG{$host};
    }
  }

DESCRIPTION ^

This plugin lets you vary a Squatting app's %CONFIG based on the host name used to make the HTTP request.

syntax highlighting: