Apache-ASP
view release on metacpan or search on metacpan
site/events.html view on Meta::CPAN
<font face="courier new" size=3><pre>
</pre></font>For many Apache::* modules for use with mod_perl, of which
Apache::ASP is just one, check out
<a href=http://perl.apache.org/src/apache-modlist.html>http://perl.apache.org/src/apache-modlist.html</a>
<font face="courier new" size=3><pre>
</pre></font>To gain access to the ASP objects like $Session outside
in a non-PerlHandler mod_perl handler, you may use this API:
<font face="courier new" size=3><pre>
my $ASP = Apache::ASP->new($r); # $r is Apache->request object
</pre></font>as in this possible Authen handler:
<font face="courier new" size=3><pre>
<Perl>
use Apache::ASP;
sub My::Auth::handler {
my $r = shift;
my $ASP = Apache::ASP->new($r)
my $Session = $ASP->Session;
}
</Perl>
</pre></font>Here are some examples of do-it-yourself mod_perl
handler programming...
<font face="courier new" size=3><pre>
=== Forbid Bad HSlide User Agent ===
# httpd.conf
PerlAccessHandler My::Access
<Perl>
sub My::Access::handler {
my $r = shift;
if($r->headers_in->{'USER_AGENT'} =~ /HSlide/) {
403;
} else {
200;
}
}
</Perl>
=== Runtime Path Parsing ===
</pre></font>This example shows how one might take an arbitrary
URL path /$path/$file.asp, and turn that into a runtime
config for your site, so your scripts get executed
always in your sites DocumentRoot.
<font face="courier new" size=3><pre>
INPUT URL /SomeCategory/
OUTPUT
Script: index.asp
$Server->Config('PATH') eq '/SomeCategory'
INPUT URL /SomeCategory/index.asp
OUTPUT
Script: index.asp
$Server->Config('PATH') eq '/SomeCategory'
INPUT URI /index.asp
OUTPUT
Script: index.asp
$Server->Config('PATH') eq ''
# httpd.conf
PerlTransHandler My::Init
use lib qw( $custom_perllib );
# $custom_perllib/My/Init.pm
package My::Init;
use strict;
use Apache::Constants qw(:common);
sub handler {
my $r = shift;
my $uri = $r->uri || '/';
unless($uri =~ m|^(.*)(/([^/.]+\.[\w]+)?)$|i) {
warn("can't parse uri $uri");
return DECLINED;
}
$uri = $2;
my $PATH = $1 || '';
$r->dir_config('PATH', $PATH);
if($uri eq '/') {
$uri = '/index.asp';
}
$r->uri($uri);
$r->filename($r->document_root.$uri);
DECLINED;
}
1;
</pre></font>
</font>
</td>
<td bgcolor=white valign=top>
</td>
</tr>
</table>
</td></tr>
</table>
</center>
</body>
</html>
( run in 0.948 second using v1.01-cache-2.11-cpan-39bf76dae61 )