Catalyst-Plugin-Redirect-0.02/0000755002352000001440000000000010357741733017172 5ustar takayamausers00000000000000Catalyst-Plugin-Redirect-0.02/t/0000755002352000001440000000000010357741733017435 5ustar takayamausers00000000000000Catalyst-Plugin-Redirect-0.02/t/02pod.t0000644002352000001440000000027610341037645020544 0ustar takayamausers00000000000000use Test::More; eval "use Test::Pod 1.14"; plan skip_all => 'Test::Pod 1.14 required' if $@; plan skip_all => 'set TEST_POD to enable this test' unless $ENV{TEST_POD}; all_pod_files_ok(); Catalyst-Plugin-Redirect-0.02/t/01use.t0000644002352000001440000000012710341037645020550 0ustar takayamausers00000000000000use strict; use Test::More tests => 1; BEGIN { use_ok('Catalyst::Plugin::Redirect') } Catalyst-Plugin-Redirect-0.02/t/03podcoverage.t0000644002352000001440000000032510341037645022254 0ustar takayamausers00000000000000use Test::More; eval "use Test::Pod::Coverage 1.04"; plan skip_all => 'Test::Pod::Coverage 1.04 required' if $@; plan skip_all => 'set TEST_POD to enable this test' unless $ENV{TEST_POD}; all_pod_coverage_ok(); Catalyst-Plugin-Redirect-0.02/META.yml0000644002352000001440000000056110357741733020445 0ustar takayamausers00000000000000# http://module-build.sourceforge.net/META-spec.html #XXXXXXX This is a prototype!!! It will change in the future!!! XXXXX# name: Catalyst-Plugin-Redirect version: 0.02 version_from: lib/Catalyst/Plugin/Redirect.pm installdirs: site requires: Catalyst: 0 distribution_type: module generated_by: ExtUtils::MakeMaker version 6.17 Catalyst-Plugin-Redirect-0.02/Changes0000644002352000001440000000047610357741066020473 0ustar takayamausers00000000000000Revision history for Perl extension Catalyst::Plugin::Redirect. 0.02 Sat Jun 07 22:04:04 2006 -fix get_baseurl use $c->req->base->host and $c->req->base->port instead of $ENV{'HTTP_HOST'}. 0.01 Sat Nov 19 03:38:31 2005 - original version; created by h2xs 1.23 with options -AX -n Catalyst::Plugin::Redirect Catalyst-Plugin-Redirect-0.02/MANIFEST0000644002352000001440000000027110357741733020323 0ustar takayamausers00000000000000Changes Makefile.PL MANIFEST README t/01use.t t/02pod.t t/03podcoverage.t lib/Catalyst/Plugin/Redirect.pm META.yml Module meta-data (added by MakeMaker) Catalyst-Plugin-Redirect-0.02/lib/0000755002352000001440000000000010357741733017740 5ustar takayamausers00000000000000Catalyst-Plugin-Redirect-0.02/lib/Catalyst/0000755002352000001440000000000010357741733021524 5ustar takayamausers00000000000000Catalyst-Plugin-Redirect-0.02/lib/Catalyst/Plugin/0000755002352000001440000000000010357741733022762 5ustar takayamausers00000000000000Catalyst-Plugin-Redirect-0.02/lib/Catalyst/Plugin/Redirect.pm0000644002352000001440000000404110357741567025065 0ustar takayamausers00000000000000package Catalyst::Plugin::Redirect; use strict; our $VERSION = '0.02'; my($Revision) = '$Id: Redirect.pm,v 1.4 2006/01/07 13:44:47 Sho Exp $'; =head1 NAME Catalyst::Plugin::Redirect - Redirect for Catalyst used easily is offered. =head1 SYNOPSIS use Catalyst 'Redirect'; $c->get_baseurl; $c->redirect('redirect_url'); $c->redirect('/redirect_url'); $c->redirect('http://www.perl.org/'); =head1 DESCRIPTION Redirect for Catalyst used easily is offered. =head1 METHODS =over 2 =item get_baseurl Basic URL of your application is returned. If your application is executed by "http://myhost/myapp/" it returns "/myapp/" . =back =cut sub get_baseurl { my $c = shift; my $base = $c->req->base; my $host = $c->req->base->host; my $port = $c->req->base->port; $base =~ s!^https?://$host:$port!!; $base =~ s!^https?://$host!!; return $base; } =over 2 =item redirect $c->redirect('redirect_url'); $c->res->redirect('redirect_url') is executed. $c->redirect('/redirect_url'); $c->res->redirect($c->get_baseurl.'redirect_url') is executed. $c->redirect('http://www.perl.org/'); $c->res->redirect('http://www.perl.org/') is executed. =back =cut sub redirect { my $c = shift; if (@_) { my $location = shift; my $status = shift || 302; if ($location =~ m!^https?://!) { return $c->res->redirect($location,$status); } elsif ($location =~ m!^/!) { my $base = $c->get_baseurl; $location = $base . $location; $location =~ s!//!/!g; return $c->res->redirect($location, $status); } else { return $c->res->redirect($location,$status); } } } =BUGS When Reverse Proxy is used, get_baseurl returns the backend server's base. For example, "/" will be returned when http://www.mydomain.com/myapp/ is a proxy for http://appserver.local.server/. =head1 SEE ALSO L =head1 AUTHOR Shota Takayama, C =head1 COPYRIGHT AND LICENSE This program is free software, you can redistribute it and/or modify it under the same terms as Perl itself. =cut 1; Catalyst-Plugin-Redirect-0.02/Makefile.PL0000644002352000001440000000060510341037645021136 0ustar takayamausers00000000000000use ExtUtils::MakeMaker; # See lib/ExtUtils/MakeMaker.pm for details of how to influence # the contents of the Makefile that is written. WriteMakefile( NAME => 'Catalyst::Plugin::Redirect', AUTHOR => 'Shota Takayam ', VERSION_FROM => 'lib/Catalyst/Plugin/Redirect.pm', # finds $VERSION PREREQ_PM => { Catalyst => 0} ); Catalyst-Plugin-Redirect-0.02/README0000644002352000001440000000211010341037645020035 0ustar takayamausers00000000000000Catalyst-Plugin-Redirect version 0.01 ===================================== The README is used to introduce the module and provide instructions on how to install the module, any machine dependencies it may have (for example C compilers and installed libraries) and any other information that should be provided before the module is installed. A README file is required for CPAN modules since CPAN extracts the README file from a module distribution so that people browsing the archive can use it get an idea of the modules uses. It is usually a good idea to provide version information here so that people can decide whether fixes for the module are worth downloading. INSTALLATION To install this module type the following: perl Makefile.PL make make test make install DEPENDENCIES This module requires these other modules and libraries: Catalyst COPYRIGHT AND LICENCE Put the correct copyright and licence information here. Copyright (C) 2005 by A. U. Thor This program is free software, you can redistribute it and/or modify it under the same terms as Perl itself.