changeset 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 3f09584bf189
children 39c8788eded5
files Lib/IMPL/Web/QueryHandler/PathInfoRewrite.pm
diffstat 1 files changed, 26 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/Lib/IMPL/Web/QueryHandler/PathInfoRewrite.pm	Tue Dec 28 14:58:17 2010 +0300
@@ -0,0 +1,26 @@
+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;
\ No newline at end of file