Skip to content

Instantly share code, notes, and snippets.

@usualoma
Created July 29, 2013 20:12
Show Gist options
  • Save usualoma/6107370 to your computer and use it in GitHub Desktop.
Save usualoma/6107370 to your computer and use it in GitHub Desktop.
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