.TH tntnet\-defcomp 1 "2013\-05\-27" Tntnet "Tntnet users guide" .SH NAME .PP tntnet \- default components for tntnet(8) .SH DESCRIPTION .PP By default tntnet can just return a http error 404 \- not found. To do something meaningful tntnet loads shared libraries with components. By defining suitable mappings in tntnet.xml(7) tntnet loads those components, which does the actual work. .PP Since in the web world there are some really basic tasks, which every web server should be able to do, tntnet brings some standard components. The shared library, which does that is called \fB\fCtntnet\fR and hence every standard component has a component identifier of \fIcomponentname\fP\fB\fC@tntnet\fR\&. They are documented here. .SS static .PP The most commonly used standard component is \fB\fCstatic@tntnet\fR\&. It gives tntnet the ability to deliver files from the file system. For this it uses the \fB\fCpathinfo\fR setting from the mapping in tntnet.xml(7) as a file name and delivers the files. The extension of the files is used to look up the content type. The same mime database is used as in the next component \fB\fCmime@tntnet\fR\&. .PP \fIExample\fP .PP .RS .nf (.*) static@tntnet /var/www/htdocs/$1 .fi .RE .PP This setting configures tntnet as simple web server for static pages. .SS mime .PP The component \fB\fCmime@tntnet\fR sets just the content type header. The value is fetched from the argument "contenttype" if set. Otherwise the path info is used to detect the correct content type from the file extension using the configured mime db. .SS empty .PP The component \fB\fCempty@tntnet\fR generates just an empty result. By default a http return code OK (200) is set but can be changed with the argument \fIhttpcode\fP\&. Other arguments are interpreted as additional http headers, so that e.g. the content type header can be set. .PP \fIExample\fP .PP .RS .nf \\.js$ empty@tntnet application/javascript .fi .RE .PP This tells tntnet to reply all requests with a url ending \fI\&.js\fP with an empty javascript file. .SS unzip .PP The component \fB\fCunzip@tntnet\fR reads static data from a zip file. The file name is read from the argument "file" and the actual file from the path info. .PP If the argument "contenttype" is set, the content type http header is set from that value. Otherwise the path info is used to look up the content type from the file extension using the configured mime db. .PP \fIExample\fP .PP .RS .nf /thefile/(.*) unzip@tntnet $1 /var/www/thefile.zip .fi .RE .PP Reads file from the specified zip file when the url starts with \fB\fC/thefile/\fR\&. The actual file in the zip file is read from the rest of the url. The content type header is set according the the file extenxion and the file is sent to the client. .SS redirect .PP The component \fB\fCredirect@tntnet\fR just returns with a redirect to another page. The location for the redirect is specified in the \fB\fC\fR setting. .PP By default a temporary redirect code (301) is sent, but can be configured by adding a configuration argument "type". The value of the type can be "temporarily", "permanently" or a number, which is used. .PP \fIExample\fP .PP .RS .nf ^/$ redirect@tntnet /login.html .fi .RE .PP This setting redirects the client to the index.html file when the root directory is requested. .PP \fIExample for a permanent redirect\fP .PP .RS .nf ^/$ redirect@tntnet /index.html permanently .fi .RE .PP This setting redirects the client to the index.html file when the root directory is requested. .SS error .PP The error component returns a specific error code to the client when called. The code is specified using the argument \fB\fC\fR and the message using the argument \fB\fC\fR\&. The message may be omitted in which case a default error code specific text is used. .PP \fIExample\fP .PP .RS .nf ^POST$ error@tntnet 405 .fi .RE .PP This setting prevents tntnet to accept POST message. .SH AUTHOR .PP This manual page was written by Tommi Mäkitalo \[la]tommi@tntnet.org\[ra]\&. .SH SEE ALSO .PP tntnet\-project(1), ecpp(7), ecppc(1), tntnet.xml(7),