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: