Created
July 29, 2013 20:12
-
-
Save usualoma/6107370 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package Plack::Middleware::MT::AliasedSearch; | |
use strict; | |
use warnings; | |
use utf8; | |
use parent 'Plack::Middleware'; | |
use Plack::Util::Accessor qw(recipes); | |
sub call { | |
my ( $self, $env ) = @_; | |
for my $recipe ( @{ $self->recipes } ) { | |
if ( $env->{PATH_INFO} =~ m!\A/$recipe->{from}\z! ) { | |
$env->{QUERY_STRING} = $recipe->{to}; | |
} | |
} | |
$self->app->($env); | |
} | |
1; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment