TclHttpd Lesson Book
22:28 PM Learn | Basic Setup | Templates | Server Security | Direct URLs | URL Domains
The TclHttpd web server is designed to be easily extended by adding Tcl code to the server. The easiest way to do this is to put all your code into a few Tcl source files in a directory known as your custom code directory. You tell the server about this with the -library command line argument, and the server automatically loads this code upon startup.
tclsh8.3 bin/httpd.tcl -library custom_directory
Note that nearly all configuration of the server is achieved by calling Tcl procedures. So, throughout the explainations here you see references to Tcl commands used to set up the server or provide URL implementations. Just put all that code into your custom code directory for it to take effect.
The interface to a web server is, of course, by the HTTP protocol in which clients ask for URLs and, optionally, provide additional query data that comes from forms. There are two basic phases in processing a URL request: access control and URL implementation.
The first phase is a Server Security check where access controls can be enforced. At this stage you can enforce password protection, require HTTPS access, check sessions, and so forth. TclHttpd allows multiple security modules to be added, and each module gets a chance to check permissions.
The second, main phase is the URL implementation. This is where the URL and associated query data is processed by the server, and results are returned to the client. In this phase, TclHttpd divides the URL namespace into subtrees called URL Domains. A URL domain is identified by the prefix of its URLs (e.g., "/status", or "/debug", or "/images"). The server comes with support for a few different kinds of URL domains, or you can implement your own custom URL domain for your application.
The Document Domain supports URLs that are mapped to regular files. The document domain allows you to plug in specialized support for different kinds of files. In particular, there is a TML Templates system that lets you embed Tcl code in your HTML page. The Tcl code gets expanded on the server before the page is returned to the client. This lets you do clever form handling, generate a common look and feel, and much more.
|Home||Status||Learn||CGI Tests||Templates||Access Control||Reference Manual|