[Deploying] | Configuration | [Customizing]
<h1>Configuring Toadhttpd</h1>
Toadhttpd will accept all of the same command line options as the httpd example from tcllib.
<p>
In addition it provides the following default behaviors:
<ul>
<li> If the file <b>config.tcl</b> is present in adjacent to httpd.tcl, it is read in as if the <b>configuration_file</b> paramter was given on the command line.
<li> If the directory <b>htdocs</b> is present in the folder that contains the <b>configuration_file</b> it is assumed to be the value for <b>doc_root</b> (if one is not given either on the command line or in the config file.)
<li> If the directory <b>log</b> is present in the folder that contains the <b>configuration_file</b> it is assumed to be the value for <b>logdir</b> (if one is not given either on the command line or in the config file.)
</ul>

<h2>configuration_file (config.tcl)</h2>
The <b>configuration_file</b> is source by the new <b>httpd::server</b> instance prior to invoking the <b>start</b> method. Because it is sourced by the object itself, you can exercise all of the object's methods via the <b>my</b> mechanism.

is probably as complicated a setup as one will encounter in the wild. It serves a number of top level domains, mixes static content and dynamic content, and even plays dispatcher to scgi based fossil repositories. On the page we will explore, in depth, how Sean configured and how you can do the same to create your own site. For now here is a simple setup to give you a sense of what is in the file:

<verbatim>
# Set a configuration parameter for the server
my config set doc_ttl 900

# Load a plugin
package require toadhttpd::sqlite
package require toadhttpd::bouncer
package require toadhttpd::fossil

##
# Inject a plugin behavior into the server object
##
my plugin bouncer
my plugin sqlite

###
# Specify how URLs are responded to
###
# Someone asking for /ccvv is up to no good, send them to the honeypot
my uri add % /ccvv {
  mixin toadhttpd::content.honeypot
}

###
# If someone asks for send them to the
# proper URL
# NOTE: This rule only applies if the server requested was
###
my uri add {
   mixinmap {reply httpd::content.redirect}
  LOCATION
}
# The page /fossil is a dynamic page with a list of fossil repos
my uri add /fossil {
   mixinmap {reply toadhttpd::content.fossil_root}
   fossil_root
   prefix fossil
 }
# Everything under that page is dispatched out to fossil SCGI
# proxies
my uri add {
    mixinmap {reply toadhttpd::content.fossil_node_scgi}
    prefix fossil
    fossil_root
 }

# The "trivial" plugin provides a cute little
# database or random facts. Accept requests at either
# /trivia or /fortune
my uri add % {/trivia /fortune} {
  mixinmap {
    reply ::etoyoc::content.trivia
    style ::etoyoc::style
  }
}
# Add /trivia to the list of places we don't like
# robots visiting
my robots.txt add /trivia

###
# Note that any URL that hasn't matched one of the rules
# above will be handled by the default hander: find the file
# under doc_root, or fail with 404
###
</verbatim>