Blame modules/examples/README

Packit 90a5c9
README for Apache 2.0 Example Module
Packit 90a5c9
[April, 1997, updated May 2000]
Packit 90a5c9
Packit 90a5c9
The files in the src/modules/examples directory under the Apache
Packit 90a5c9
distribution directory tree are provided as an example to those that
Packit 90a5c9
wish to write modules that use the Apache API.
Packit 90a5c9
Packit 90a5c9
The main file is mod_example_hooks.c, which illustrates all the different
Packit 90a5c9
callback mechanisms and call syntaces.  By no means does an add-on
Packit 90a5c9
module need to include routines for all of the callbacks - quite the
Packit 90a5c9
contrary!
Packit 90a5c9
Packit 90a5c9
The example module is an actual working module.  If you link it into
Packit 90a5c9
your server, enable the "example-hooks-handler" handler for a location,
Packit 90a5c9
and then browse to that location, you will see a display of some of the
Packit 90a5c9
tracing the example module did as the various callbacks were made.
Packit 90a5c9
Packit 90a5c9
To include the example module in your server add --enable-example-hooks
Packit 90a5c9
to the other ./configure arguments executed from the httpd source tree.
Packit 90a5c9
After that run 'make'.
Packit 90a5c9
Packit 90a5c9
To add another module of your own:
Packit 90a5c9
Packit 90a5c9
    A. cp modules/examples/mod_example_hooks.c modules/examples/mod_myexample.c
Packit 90a5c9
    B. Modify the file
Packit 90a5c9
    C. Add an entry to modules/examples/config.m4, e.g.
Packit 90a5c9
         APACHE_MODULE(myexample, my new module, , , no)
Packit 90a5c9
       The last argument specifies if the module is built by-default
Packit 90a5c9
    D. Build the server with --enable-myexample
Packit 90a5c9
Packit 90a5c9
For windows, the process is slightly different;
Packit 90a5c9
Packit 90a5c9
    A. copy modules\examples\mod_example_hooks.c modules\examples\mod_myexample.c
Packit 90a5c9
    B. copy modules\examples\mod_example_hooks.dsp modules\examples\mod_myexample.dsp
Packit 90a5c9
    C. replace the occurrences of 'example_hooks' with your module name.
Packit 90a5c9
    D. add the new .dsp to your Apache.dsw workspace, with dependencies
Packit 90a5c9
       on the libapr, libaprutil and libhttpd projects.  With the newer
Packit 90a5c9
       Developer Studio 2002 through 2005, when you add the new .dsp
Packit 90a5c9
       file it will be converted to a .vcproj file.
Packit 90a5c9
Packit 90a5c9
To activate the example module, include a block similar to the
Packit 90a5c9
following in your httpd.conf file:
Packit 90a5c9
Packit 90a5c9
    <Location /example-info>
Packit 90a5c9
	SetHandler example-hooks-handler
Packit 90a5c9
    </Location>
Packit 90a5c9
Packit 90a5c9
As an alternative, you can put the following into a .htaccess file and
Packit 90a5c9
then request the file "test.example" from that location:
Packit 90a5c9
Packit 90a5c9
    AddHandler example-hooks-handler .example
Packit 90a5c9
Packit 90a5c9
After reloading/restarting your server, you should be able to browse
Packit 90a5c9
to this location and see the brief display mentioned earlier.