Cache-Module=/full/path/to/foo
The program foo should be an interface to your database. It is permissable to follow "foo" in this line with any desired arguments to be passed to it. The program foo should read the environment variable WN_KEY which will contain everything after the final '/' in the URL being served. Based on this key it should return a single line in the format of an index.cache file. The format of this file is documented in docs/cacheformat. Any File= directives in an index file which contains a Cache-module= directive will be ignored.
You may wish the cache module function to have access to more information about the request. If you put the directive Default-attributes=cgi before the Cache-Module directive then all the CGI environment variables will be set.
If the file cache module encounters an error, such as no entry corresponding to the supplied key, it should return nothing and exit with a negative status. This signals the server to return an appropriate error message.
File-Module=/full/path/to/bar
The program "bar" should be an interface to your database. It should read the environment variable WN_KEY which will contain everything after the final '/' in the URL being served. Based on this key it should return a document to be served (perhaps after processing with wrappers or includes). When a file module is used it is also necessary to either use a Cache-module or have an actual index.cache file with the name of all documents which might be returned by the database or to have an index.cache file created from an index file containing the directory directive "Attributes=serveall". If the file module encounters an error, such as no document corresponding to the supplied key, it should return an appropriate error message of the same content-type as the requested document.
As with cache modules, you may wish the file module function to have access to more information about the request. If you put the directive Default-attributes=cgi before the File-Module directive in your index file then all the CGI environment variables will be set.
The contents the Authorization: request header is passed to the module on standard input (as of version 1.10).
The server expects this module to exit with a status indicating that access is granted, denied, or that an error occurred. Anyone writing an authorization module should consult the file /authwn/authwn.h. The #defines listed there specify the error status to use for granting, denying or indicating certain errors.
To use a user supplied authorization module named authmod the index file of each directory requiring authorization should contain lines like
Authorization-realm=myrealm
Authorization-module=/full/path/to/authmod
Authorization-type=basic
The program authmod should indicate the granting or denial of authorization by its exit status as described above. The Authorization realm is a designation which is sent to the client with the authorization request allowing the client to decide whether the user has already supplied a password which can be reused (if the realm is the same as when the password was supplied) or if a new password needs to be entered.
Then in the index file in the directory dir you should have a line like
Search-Module=/full/path/to/searchmod
The program searchmod should read the environment variable QUERY_STRING and return a partial HTML document. The typical case would be the program returns an unordered list of anchors to documents containing a match to the query string. This list can be wrapped by including a Searchwrapper directory record. If it is not, a default wrapper with text like "Here are the matches for your search" is supplied.
Two simple examples of a search-module (written in perl) are included in the distribution in the files bin/seven_m and bin/sectsearch.