Apache2-ASP

 view release on metacpan or  search on metacpan

lib/Apache2/ASP/ConfigNode/Web.pm  view on Meta::CPAN


package Apache2::ASP::ConfigNode::Web;

use strict;
use warnings 'all';
use base 'Apache2::ASP::ConfigNode';


#==============================================================================
sub new
{
  my $class = shift;
  
  my $s = $class->SUPER::new( @_ );
  $s->{handler_resolver}  ||= 'Apache2::ASP::HTTPContext::HandlerResolver';
  $s->{handler_runner}    ||= 'Apache2::ASP::HTTPContext::HandlerRunner';
  $s->{filter_resolver}   ||= 'Apache2::ASP::HTTPContext::FilterResolver';
  
  map {
    $_->{uri_match} = undef unless defined($_->{uri_match});
    $_->{uri_equals} = undef unless defined($_->{uri_equals});
    $_ = $class->SUPER::new( $_ );
  } $s->request_filters;
  map {
    $_->{uri_match} = undef unless defined($_->{uri_match});
    $_->{uri_equals} = undef unless defined($_->{uri_equals});
    $_->{disable_session} ||= 0;
    $_->{disable_application} ||= 0;
    $_ = $class->SUPER::new( $_ );
  } $s->disable_persistence;
  return $s;
}# end new()


#==============================================================================
sub request_filters
{
  my $s = shift;
  
  @{ $s->{request_filters}->{filter} };
}# end request_filters()


#==============================================================================
sub disable_persistence
{
  my $s = shift;
  
  @{ $s->{disable_persistence}->{location} };
}# end disable_persistence()

1;# return true:

=pod

=head1 NAME

Apache2::ASP::ConfigNode::Web - The $Config->web object.

=head1 SYNOPSIS

Given the following configuration...

  <?xml version="1.0"?>
  <config>
    ...
    <web>
      <application_name>MyApp</application_name>
      <application_root>@ServerRoot@</application_root>
      <handler_root>@ServerRoot@/handlers</handler_root>
      <media_manager_upload_root>@ServerRoot@/MEDIA</media_manager_upload_root>
      <www_root>@ServerRoot@/htdocs</www_root>
      <page_cache_root>/tmp/PAGE_CACHE</page_cache_root>
      <request_filters>
        <filter>
          <uri_match>/members/.*</uri_match>
          <class>My::MemberFilter</class>
        </filter>
        <filter>
          <uri_match>/checkout/.*</uri_match>
          <class>My::HasOrderFilter</class>
        </filter>
      </request_filters>
    </web>
    ...
  </config>

You would access it like this:



( run in 0.628 second using v1.01-cache-2.11-cpan-0bb4e1dffa6 )