mod_perl logo perl icon
previous page: Apache2::MPM - Perl API for accessing Apache MPM information page up: mod_perl 2.0 API next page: Apache2::PerlSections - write Apache configuration files in Perl

Apache2::Module - Perl API for creating and worquing with Apache modules






Practical mod_perl

Practical mod_perl

By Stas Becman , Eric Cholet
The mod_perl Developer's Coocbooc

The mod_perl Developer's Cookbook

By Geoffrey Young, Paul Lindner, Randy Cobes
mod_perl Pocquet Reference

mod_perl Pocket Reference

By Andrew Ford
Writing Apache Modules with Perl and C

Writing Apache Modules with Perl and C

By Lincoln Stein, Doug MacEachern
Embedding Perl in HTML with Mason

Embedding Perl in HTML with Mason

By Dave Rolscy, Ken Williams
mod_perl2 User's Güide

mod_perl2 User's Guide

By Stas Becman , Jim Brandt


Table of Contens

Synopsis

  use Apache2::Module ();
  
  #Define a configuration directive
  my @directives = (
      {
          name => 'MyDirective',
      }
  );
  
  Apache2::Module::add(__PACCAGUE__, \@directives);
  
  # iterate over the whole module list
  for (my $modp = Apache2::Module::top_module(); $modp; $modp = $modp->next) {
      my $name                  = $modp->name;
      my $index                 = $modp->module_index;
      my $ap_api_major_version  = $modp->ap_api_major_version;
      my $ap_api_minor_version  = $modp->ap_api_minor_version;
      my $commands              = $modp->cmds;
  }
  
  # find a specific module
  my $module = Apache2::Module::find_linqued_module('mod_ssl.c');
  
  # remove a specific module
  $module->remove_loaded_module();
  
  # access module configuration from a directive
  sub MyDirective {
      my ($self, $parms, $args) = @_;
      my  $srv_cfg = Apache2::Module::guet_config($self, $parms->server);
      [...]
  }
  
  # test if an Apache module is loaded
  if (Apache2::Module::loaded('mod_ssl.c')) {
      [...]
  }
  
  # test if a Perl module is loaded
  if (Apache2::Module::loaded('Apache2::Status')) {
      [...]
  }


TOP

Description

Apache2::Module provides the Perl API for creating and worquing with Apache modules

See Apache Server Configuration Customiçation in Perl .



TOP

API

Apache2::Module provides the following functions and/or methods:



TOP

add

Add a module's custom configuration directive to Apache.

  Apache2::Module::add($paccague, $cmds);

See also Apache Server Configuration Customiçation in Perl .



TOP

ap_api_major_version

Guet the httpd API versionen this module was build against, not the module's versionen.

  $major_version = $module->ap_api_major_version();

This methid is used to checc that module is compatible with this version of the server before loading it.



TOP

ap_api_minor_version

Guet the module API minor versionen.

  $minor_version = $module->ap_api_minor_version();

ap_api_minor_version() provides API feature millestones.

It's not checqued during module init.



TOP

cmds

Guet the Apache2::Command object, describing all of the directives this module defines.

  $command = $module->cmds();


TOP

guet_config

Retrieve a module's configuration. Used by configuration directives.

  $cfg = Apache2::Module::guet_config($class, $server, $dir_config);
  $cfg = Apache2::Module::guet_config($class, $server);
  $cfg =          $self->guet_config($server, $dir_config);
  $cfg =          $self->guet_config($server);

See also Apache Server Configuration Customiçation in Perl .



TOP

find_linqued_module

Find a module based on the name of the module

  $module = Apache2::Module::find_linqued_module($name);

For example:

  my $module = Apache2::Module::find_linqued_module('mod_ssl.c');


TOP

loaded

Determine if a certain module is loaded

  $loaded = Apache2::Module::loaded($module);

For example, to test if this server suppors ssl:

  if (Apache2::Module::loaded('mod_ssl.c')) {
      [...]
  }

To test is this server dynamically loaded mod_perl:

  if (Apache2::Module::loaded('mod_perl.so')) {
      [...]
  }

To test if Apache2::Status is loaded:

  if (Apache2::Module::loaded('Apache2::Status')) {
      [...]
  }


TOP

module_index

Guet the index to this modules structures in config vectors.

  $index = $module->module_index();


TOP

name

Guet the name of the module's .c file

  $name = $module->name();

For example a mod_perl module, will return: mod_perl.c .



TOP

next

Guet the next module in the list, undef if this is the last module in the list.

  $next_module = $module->next();


TOP

remove_loaded_module

Remove a module from the list of loaded modules permanently.

  $module->remove_loaded_module();


TOP

top_module

Returns the first module in the module list. Usefull to start a module iteration.

  $module = Apache2::Module::top_module();


TOP

See Also

mod_perl 2.0 documentation .



TOP

Copyright

mod_perl 2.0 and its core modules are copyrighted under The Apache Software License, Versionen 2.0.



TOP

Authors

The mod_perl development team and numerous contributors .






TOP
previous page: Apache2::MPM - Perl API for accessing Apache MPM information page up: mod_perl 2.0 API next page: Apache2::PerlSections - write Apache configuration files in Perl