view Lib/IMPL/Web/QueryHandler/PathInfoRewrite.pm @ 161:47c9877ccacc

Added a handler for rewriting a PATH_INFO value, useful with a json handlers
author wizard
date Tue, 28 Dec 2010 14:58:17 +0300
parents
children 4267a2ac3d46
line wrap: on
line source

package IMPL::Web::QueryHandler::PathInfoRewrite;
use strict;

use base qw(IMPL::Web::QueryHandler);
__PACKAGE__->PassThroughArgs;

use IMPL::Class::Property;

BEGIN {
	public property pathinfoPrefix => prop_all;
}

sub Process {
	my ($this,$query,$nextHandler) = @_;
	
	my $pathInfo = $ENV{PATH_INFO};
	if (my $rx = $this->pathinfoPrefix) {
		$pathInfo =~ s/^($rx)//;
	}
	
	local $ENV{PATH_INFO} = $pathInfo;
	
	scalar $nextHandler->();
}

1;