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-&gt;new($r); # $r is Apache-&gt;request object
</pre></font>as in this possible Authen handler:
<font face="courier new" size=3><pre>
  &lt;Perl&gt;
    use Apache::ASP;
    sub My::Auth::handler {
      my $r = shift;
      my $ASP = Apache::ASP-&gt;new($r) 
      my $Session = $ASP-&gt;Session;
    }
  &lt;/Perl&gt;
</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
 &lt;Perl&gt;
   sub My::Access::handler {
     my $r = shift;
     if($r-&gt;headers_in-&gt;{&#39;USER_AGENT&#39;} =~ /HSlide/) {
	 403;
     } else {
	 200;
     }
   }
 &lt;/Perl&gt;

 === 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-&gt;Config(&#39;PATH&#39;) eq &#39;/SomeCategory&#39;

 INPUT URL /SomeCategory/index.asp
 OUTPUT
  Script: index.asp
  $Server-&gt;Config(&#39;PATH&#39;) eq &#39;/SomeCategory&#39;

 INPUT URI /index.asp
 OUTPUT
  Script: index.asp
  $Server-&gt;Config(&#39;PATH&#39;) eq &#39;&#39;

 # 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-&gt;uri || &#39;/&#39;;
    unless($uri =~ m|^(.*)(/([^/.]+\.[\w]+)?)$|i) {
	warn(&quot;can&#39;t parse uri $uri&quot;);
	return DECLINED;
    }
    $uri = $2;
    my $PATH = $1 || &#39;&#39;;
    $r-&gt;dir_config(&#39;PATH&#39;, $PATH);

    if($uri eq &#39;/&#39;) {
	$uri = &#39;/index.asp&#39;;
    }

    $r-&gt;uri($uri);
    $r-&gt;filename($r-&gt;document_root.$uri);

    DECLINED;
 }

 1;
</pre></font>
	

</font>
</td>

<td bgcolor=white valign=top>
&nbsp;
</td>

</tr>
</table>

</td></tr>
</table>
</center>

</body>
</html>



( run in 0.948 second using v1.01-cache-2.11-cpan-39bf76dae61 )