mod_example.html revision eb3e63593a2f2ec26386769e782ce9e77536a779
65fea56f17cd614bc8908264df980a62e1931468vboxsync<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
65fea56f17cd614bc8908264df980a62e1931468vboxsync<HTML>
65fea56f17cd614bc8908264df980a62e1931468vboxsync <HEAD>
65fea56f17cd614bc8908264df980a62e1931468vboxsync <TITLE>Apache module mod_example</TITLE>
65fea56f17cd614bc8908264df980a62e1931468vboxsync </HEAD>
65fea56f17cd614bc8908264df980a62e1931468vboxsync <BODY>
65fea56f17cd614bc8908264df980a62e1931468vboxsync <!--#include virtual="header.html" -->
65fea56f17cd614bc8908264df980a62e1931468vboxsync <H1>Module mod_example</h1>
65fea56f17cd614bc8908264df980a62e1931468vboxsync <P>
65fea56f17cd614bc8908264df980a62e1931468vboxsync This module is contained in the <CODE>modules/mod_example.c</CODE> file, and
65fea56f17cd614bc8908264df980a62e1931468vboxsync <STRONG>is not</STRONG> compiled in by default. It illustrates many of
65fea56f17cd614bc8908264df980a62e1931468vboxsync the aspects of the
65fea56f17cd614bc8908264df980a62e1931468vboxsync <A
65fea56f17cd614bc8908264df980a62e1931468vboxsync HREF="/misc/API.html"
65fea56f17cd614bc8908264df980a62e1931468vboxsync REL="Help"
65fea56f17cd614bc8908264df980a62e1931468vboxsync >Apache 1.2 API</A>
65fea56f17cd614bc8908264df980a62e1931468vboxsync and, when used, demonstrates the manner in which module callbacks are
65fea56f17cd614bc8908264df980a62e1931468vboxsync triggered by the server.
65fea56f17cd614bc8908264df980a62e1931468vboxsync </P>
65fea56f17cd614bc8908264df980a62e1931468vboxsync <H2>Summary</H2>
65fea56f17cd614bc8908264df980a62e1931468vboxsync <P>
65fea56f17cd614bc8908264df980a62e1931468vboxsync The files in the <CODE>src/modules/example directory</CODE> under the
65fea56f17cd614bc8908264df980a62e1931468vboxsync Apache distribution directory tree are provided as an example to those
65fea56f17cd614bc8908264df980a62e1931468vboxsync that wish to write modules that use the Apache API.
65fea56f17cd614bc8908264df980a62e1931468vboxsync </P>
65fea56f17cd614bc8908264df980a62e1931468vboxsync <P>
65fea56f17cd614bc8908264df980a62e1931468vboxsync The main file is <CODE>mod_example.c</CODE>, which illustrates all
65fea56f17cd614bc8908264df980a62e1931468vboxsync the different callback mechanisms and call syntaces. By no means does
65fea56f17cd614bc8908264df980a62e1931468vboxsync an add-on module need to include routines for all of the callbacks -
65fea56f17cd614bc8908264df980a62e1931468vboxsync quite the contrary!
65fea56f17cd614bc8908264df980a62e1931468vboxsync </P>
65fea56f17cd614bc8908264df980a62e1931468vboxsync <P>
65fea56f17cd614bc8908264df980a62e1931468vboxsync The example module is an actual working module. If you link it into
65fea56f17cd614bc8908264df980a62e1931468vboxsync your server, enable the "example-handler" handler for a location, and
65fea56f17cd614bc8908264df980a62e1931468vboxsync then browse to that location, you will see a display of
65fea56f17cd614bc8908264df980a62e1931468vboxsync some of the tracing the example module did as the various callbacks
65fea56f17cd614bc8908264df980a62e1931468vboxsync were made.
65fea56f17cd614bc8908264df980a62e1931468vboxsync </P>
65fea56f17cd614bc8908264df980a62e1931468vboxsync <P>
65fea56f17cd614bc8908264df980a62e1931468vboxsync To include the example module in your server, follow the steps below:
65fea56f17cd614bc8908264df980a62e1931468vboxsync </P>
65fea56f17cd614bc8908264df980a62e1931468vboxsync <OL>
65fea56f17cd614bc8908264df980a62e1931468vboxsync <LI>Uncomment the "Module example_module" line near the bottom of
65fea56f17cd614bc8908264df980a62e1931468vboxsync the <CODE>src/Configuration</CODE> file. If there isn't one, add
65fea56f17cd614bc8908264df980a62e1931468vboxsync it; it should look like this:
65fea56f17cd614bc8908264df980a62e1931468vboxsync <PRE>
65fea56f17cd614bc8908264df980a62e1931468vboxsync Module example_module modules/example/mod_example.o
65fea56f17cd614bc8908264df980a62e1931468vboxsync </PRE>
65fea56f17cd614bc8908264df980a62e1931468vboxsync </LI>
65fea56f17cd614bc8908264df980a62e1931468vboxsync <LI>Run the <CODE>src/Configure</CODE> script
65fea56f17cd614bc8908264df980a62e1931468vboxsync ("<SAMP>cd&nbsp;src;&nbsp;/Configure</SAMP>"). This will
65fea56f17cd614bc8908264df980a62e1931468vboxsync build the Makefile for the server itself, and update the
65fea56f17cd614bc8908264df980a62e1931468vboxsync <CODE>src/modules/Makefile</CODE> for any additional modules you
65fea56f17cd614bc8908264df980a62e1931468vboxsync have requested from beneath that subdirectory.
65fea56f17cd614bc8908264df980a62e1931468vboxsync </LI>
65fea56f17cd614bc8908264df980a62e1931468vboxsync <LI>Make the server (run "<SAMP>make</SAMP>" in the <CODE>src</CODE>
65fea56f17cd614bc8908264df980a62e1931468vboxsync directory).
65fea56f17cd614bc8908264df980a62e1931468vboxsync </LI>
65fea56f17cd614bc8908264df980a62e1931468vboxsync </OL>
65fea56f17cd614bc8908264df980a62e1931468vboxsync <P>
65fea56f17cd614bc8908264df980a62e1931468vboxsync To add another module of your own:
65fea56f17cd614bc8908264df980a62e1931468vboxsync </P>
65fea56f17cd614bc8908264df980a62e1931468vboxsync <OL TYPE="A">
65fea56f17cd614bc8908264df980a62e1931468vboxsync <LI><SAMP>mkdir src/modules/<EM>mymodule</EM></SAMP>
65fea56f17cd614bc8908264df980a62e1931468vboxsync </LI>
65fea56f17cd614bc8908264df980a62e1931468vboxsync <LI><SAMP>cp src/modules/example/* src/modules/<EM>mymodule</EM></SAMP>
65fea56f17cd614bc8908264df980a62e1931468vboxsync </LI>
65fea56f17cd614bc8908264df980a62e1931468vboxsync <LI>Modify the files in the new directory.
65fea56f17cd614bc8908264df980a62e1931468vboxsync </LI>
65fea56f17cd614bc8908264df980a62e1931468vboxsync <LI>Follow steps [1] through [3] above, with appropriate changes.
65fea56f17cd614bc8908264df980a62e1931468vboxsync </LI>
65fea56f17cd614bc8908264df980a62e1931468vboxsync </OL>
65fea56f17cd614bc8908264df980a62e1931468vboxsync <H3>
65fea56f17cd614bc8908264df980a62e1931468vboxsync Using the <SAMP>mod_example</SAMP> Module
65fea56f17cd614bc8908264df980a62e1931468vboxsync </H3>
65fea56f17cd614bc8908264df980a62e1931468vboxsync <P>
65fea56f17cd614bc8908264df980a62e1931468vboxsync To activate the example module, include a block similar to the
65fea56f17cd614bc8908264df980a62e1931468vboxsync following in your <SAMP>srm.conf</SAMP> file:
65fea56f17cd614bc8908264df980a62e1931468vboxsync </P>
65fea56f17cd614bc8908264df980a62e1931468vboxsync <PRE>
65fea56f17cd614bc8908264df980a62e1931468vboxsync &lt;Location /example-info&gt;
65fea56f17cd614bc8908264df980a62e1931468vboxsync SetHandler example-handler
65fea56f17cd614bc8908264df980a62e1931468vboxsync &lt;/Location&gt;
65fea56f17cd614bc8908264df980a62e1931468vboxsync </PRE>
65fea56f17cd614bc8908264df980a62e1931468vboxsync <P>
65fea56f17cd614bc8908264df980a62e1931468vboxsync As an alternative, you can put the following into a
65fea56f17cd614bc8908264df980a62e1931468vboxsync <A
65fea56f17cd614bc8908264df980a62e1931468vboxsync HREF="core.html#accessfilename"
65fea56f17cd614bc8908264df980a62e1931468vboxsync ><SAMP>.htaccess</SAMP></A>
65fea56f17cd614bc8908264df980a62e1931468vboxsync file and then request the file &quot;test.example&quot; from that
65fea56f17cd614bc8908264df980a62e1931468vboxsync location:
65fea56f17cd614bc8908264df980a62e1931468vboxsync </P>
65fea56f17cd614bc8908264df980a62e1931468vboxsync <PRE>
65fea56f17cd614bc8908264df980a62e1931468vboxsync AddHandler example-handler .example
65fea56f17cd614bc8908264df980a62e1931468vboxsync </PRE>
65fea56f17cd614bc8908264df980a62e1931468vboxsync <P>
65fea56f17cd614bc8908264df980a62e1931468vboxsync After reloading/restarting your server, you should be able to browse
65fea56f17cd614bc8908264df980a62e1931468vboxsync to this location and see the brief display mentioned earlier.
65fea56f17cd614bc8908264df980a62e1931468vboxsync </P>
65fea56f17cd614bc8908264df980a62e1931468vboxsync <H2>Directives</H2>
65fea56f17cd614bc8908264df980a62e1931468vboxsync <P>
65fea56f17cd614bc8908264df980a62e1931468vboxsync <UL>
65fea56f17cd614bc8908264df980a62e1931468vboxsync <LI><A HREF="#example">Example</A>
65fea56f17cd614bc8908264df980a62e1931468vboxsync </LI>
65fea56f17cd614bc8908264df980a62e1931468vboxsync </UL>
65fea56f17cd614bc8908264df980a62e1931468vboxsync </P>
65fea56f17cd614bc8908264df980a62e1931468vboxsync <HR>
65fea56f17cd614bc8908264df980a62e1931468vboxsync <A NAME="example">
65fea56f17cd614bc8908264df980a62e1931468vboxsync <H2>Example</H2>
65fea56f17cd614bc8908264df980a62e1931468vboxsync </A>
65fea56f17cd614bc8908264df980a62e1931468vboxsync <P>
65fea56f17cd614bc8908264df980a62e1931468vboxsync <STRONG>Syntax:</STRONG> Example
65fea56f17cd614bc8908264df980a62e1931468vboxsync <BR>
65fea56f17cd614bc8908264df980a62e1931468vboxsync <STRONG>Default:</STRONG> None
65fea56f17cd614bc8908264df980a62e1931468vboxsync <BR>
65fea56f17cd614bc8908264df980a62e1931468vboxsync <STRONG>Context:</STRONG> server config, virtual host, directory, .htaccess
65fea56f17cd614bc8908264df980a62e1931468vboxsync <BR>
65fea56f17cd614bc8908264df980a62e1931468vboxsync <STRONG>Override:</STRONG> Options
65fea56f17cd614bc8908264df980a62e1931468vboxsync <BR>
65fea56f17cd614bc8908264df980a62e1931468vboxsync <STRONG>Status:</STRONG> Extension
65fea56f17cd614bc8908264df980a62e1931468vboxsync <BR>
65fea56f17cd614bc8908264df980a62e1931468vboxsync <STRONG>Module:</STRONG> mod_example
65fea56f17cd614bc8908264df980a62e1931468vboxsync </P>
65fea56f17cd614bc8908264df980a62e1931468vboxsync <P>
65fea56f17cd614bc8908264df980a62e1931468vboxsync The Example directive activates the example module's content handler
65fea56f17cd614bc8908264df980a62e1931468vboxsync for a particular location or file type. It takes no arguments. If
65fea56f17cd614bc8908264df980a62e1931468vboxsync you browse to an URL to which the example content-handler applies, you
65fea56f17cd614bc8908264df980a62e1931468vboxsync will get a display of the routines within the module and how and in
65fea56f17cd614bc8908264df980a62e1931468vboxsync what order they were called to service the document request.
65fea56f17cd614bc8908264df980a62e1931468vboxsync </P>
65fea56f17cd614bc8908264df980a62e1931468vboxsync <!--#include virtual="footer.html" -->
65fea56f17cd614bc8908264df980a62e1931468vboxsync </BODY>
65fea56f17cd614bc8908264df980a62e1931468vboxsync</HTML>
65fea56f17cd614bc8908264df980a62e1931468vboxsync