Cookie - A cookie based dispatcher


Apache2-Mogile-Dispatch documentation Contained in the Apache2-Mogile-Dispatch distribution.

Index


Code Index:

NAME

Top

Cookie - A cookie based dispatcher

DESCRIPTION

Top

This example module shows how to use cookies to determine if mogile is to be used or not. It takes advantage of the apache request object being passed to make its deciscion.

AUTHOR

Top

Nick Gerakines, <nick at socklabs.com>

SUPPORT

Top

You can find documentation for this module with the perldoc command.

  perldoc Apache2::Mogile::Dispatch

COPYRIGHT & LICENSE

Top


Apache2-Mogile-Dispatch documentation Contained in the Apache2-Mogile-Dispatch distribution.

package Cookie;

use strict;
use warnings;

use base 'Apache2::Mogile::Dispatch';

use Apache2::Cookie;
use Apache2::Cookie::Jar;

sub mogile_key {
    my ($r) = @_;
    return $r->uri;
}

sub get_direction {
    my ($r, $cf) = @_;
    my $j = Apache2::Cookie::Jar->new($r);
    my $cookie = $j->cookies('mogile');
    if (! $cookie) { return { 'mogile' => 0 }; }
    if ($cookie->value eq 'true') { return { 'mogile' => 1 }; }
    return { 'mogile' => 0 };
}

sub get_config {
    return {
        'MogTrackers' => [ 'localhost:11211', 'localhost:11212'],
        'MogStaticServers' => ['localhost:80'],
        'MogDomain' => 'localhost',
    };
}

sub reproxy_request {
    return 1;
}

1;
__END__