x
Loading
 Loading
Hello, Guest | Login | Register

Introduction to mod_perl, Part Three

In the final of a three-part series, see how to use the mod_perl API and affect the processing of Apache’s many phases.


Introduction to mod_perl (part3)

Last month, I took a well-needed break, giving my space up formatters related to Perl6. Thank you, guest writers and thank youeditors!

In the previous two columns, I introduced mod_perl,including fundamental concepts, basic configuration directives, andstarted describing the callback API objects.

In this month, I’ll finish my introduction tomod_perl by talking about the rest of the API, showingsome sample code to use in the content and other phases, and thenconclude with some pointers to further information.

The Apache request object, often referred to as $r,can be obtained as the first parameter passed in to a handlersubroutine, or via the request method of theApache class. Calling methods against this objectgenerally triggers callbacks to the published Apache API. Forexample, document_root can get (or even set) the“document root'’ (the directory that the root URL initially isdirected). Although you might be tempted to compute a URL relativeto this directory, be aware that some directives such asAlias will further modify this mapping.

Another interesting request method is dir_config,which provides access to the PerlSetVar andPerlAddVar values. For example,

my @items =$r->dir_config->get(’SomeKey’);

sets @items to the zero or moreSomeKey (case insensitive) values seen in the variousconfiguration files appropriate to the current request. Thismechanism permits a simple configuration change to modify thebehavior of code in a syntax that is config-file compatible.

Handlers can pass notes to each other during theexecution of a…

Please log in to view this content.

Not Yet a Member?

Register with LinuxMagazine.com and get free access to the entire archive, including:

  • Hands-on Content
  • White Papers
  • Community Features
  • And more.
Already a Member?
Log in!
Username

Password

Remember me

Forgotten your password?
Forgotten your username?
Read More
  1. Helpful Tools for Software Developers
  2. The Github Hall of Fame
  3. Book'em, Github.
  4. This Week on Github: Stupid Ruby Tricks
  5. A Veritable Scatter Shot!
Follow Linux Magazine
Rackspace