1tntnet-defcomp(1)             Tntnet users guide             tntnet-defcomp(1)
2
3
4

NAME

6       tntnet - default components for tntnet(8)
7
8

DESCRIPTION

10       By  default  tntnet can just return a http error 404 - not found. To do
11       something meaningful tntnet loads shared libraries with components.  By
12       defining  suitable  mappings in tntnet.xml(7) tntnet loads those compo‐
13       nents, which does the actual work.
14
15
16       Since in the web world there are some really basic tasks,  which  every
17       web  server  should  be  able to do, tntnet brings some standard compo‐
18       nents. The shared library, which does that is called tntnet  and  hence
19       every  standard  component  has  a  component  identifier of component‐
20       name@tntnet. They are documented here.
21
22
23   static
24       The most commonly used standard component is  static@tntnet.  It  gives
25       tntnet  the  ability to deliver files from the file system. For this it
26       uses the pathinfo setting from the mapping in tntnet.xml(7) as  a  file
27       name and delivers the files. The extension of the files is used to look
28       up the content type. The same mime database is used as in the next com‐
29       ponent mime@tntnet.
30
31
32       Example
33
34
35              <mapping>
36                <url>(.*)</url>
37                <target>static@tntnet</target>
38                <pathinfo>/var/www/htdocs/$1</pathinfo>
39              </mapping>
40
41
42
43       This setting configures tntnet as simple web server for static pages.
44
45
46   mime
47       The  component mime@tntnet sets just the content type header. The value
48       is fetched from the argument "contenttype" if set. Otherwise  the  path
49       info is used to detect the correct content type from the file extension
50       using the configured mime db.
51
52
53   empty
54       The component empty@tntnet generates just an empty result. By default a
55       http  return  code OK (200) is set but can be changed with the argument
56       httpcode.  Other arguments are interpreted as additional http  headers,
57       so that e.g. the content type header can be set.
58
59
60       Example
61
62
63              <mapping>
64                <url>\.js$</url>
65                <target>empty@tntnet</target>
66                <args>
67                  <ContentType>application/javascript</ContentType>
68                </args>
69              </mapping>
70
71
72
73       This  tells  tntnet to reply all requests with a url ending .js with an
74       empty javascript file.
75
76
77   unzip
78       The component unzip@tntnet reads static data from a zip file. The  file
79       name is read from the argument "file" and the actual file from the path
80       info.
81
82
83       If the argument "contenttype" is set, the content type http  header  is
84       set  from  that  value.  Otherwise the path info is used to look up the
85       content type from the file extension using the configured mime db.
86
87
88       Example
89
90
91              <mapping>
92                <url>/thefile/(.*)</url>
93                <target>unzip@tntnet</target>
94                <pathinfo>$1</pathinfo>
95                <args>
96                  <file>/var/www/thefile.zip</file>
97                </args>
98              </mapping>
99
100
101
102       Reads file from the specified zip file when the url starts  with  /the‐
103       file/.  The  actual  file  in the zip file is read from the rest of the
104       url. The content type header is set according the  the  file  extenxion
105       and the file is sent to the client.
106
107
108   redirect
109       The  component  redirect@tntnet just returns with a redirect to another
110       page.  The location for the redirect is  specified  in  the  <pathinfo>
111       setting.
112
113
114       By  default a temporary redirect code (301) is sent, but can be config‐
115       ured by adding a configuration argument "type". The value of  the  type
116       can be "temporarily", "permanently" or a number, which is used.
117
118
119       Example
120
121
122              <mapping>
123                <url>^/$</url>
124                <target>redirect@tntnet</target>
125                <redirect>/login.html</redirect>
126              </mapping>
127
128
129
130       This  setting redirects the client to the index.html file when the root
131       directory is requested.
132
133
134       Example for a permanent redirect
135
136
137              <mapping>
138                <url>^/$</url>
139                <target>redirect@tntnet</target>
140                <redirect>/index.html</redirect>
141                <args>
142                  <type>permanently</type>
143                </args>
144              </mapping>
145
146
147
148       This setting redirects the client to the index.html file when the  root
149       directory is requested.
150
151
152   error
153       The  error  component  returns a specific error code to the client when
154       called. The code is specified using the argument <code> and the message
155       using  the argument <message>. The message may be omitted in which case
156       a default error code specific text is used.
157
158
159       Example
160
161
162              <mapping>
163                <method>^POST$</method>
164                <target>error@tntnet</target>
165                <args>
166                  <code>405</code>
167                </args>
168              </mapping>
169
170
171
172       This setting prevents tntnet to accept POST message.
173
174

AUTHOR

176       This manual page was written by Tommi Mäkitalo ⟨tommi@tntnet.org⟩.
177
178

SEE ALSO

180       tntnet-project(1), ecpp(7), ecppc(1), tntnet.xml(7),
181
182
183
184Tntnet                            2013-05-27                 tntnet-defcomp(1)
Impressum