tntnet-defcomp(1)
π tntnet-defcomp β default components for tntnet(8) π
okay bestie, welcome to the Tntnet users guide, the little corner of the man pages where we talk about the starter pack components. sit down, grab a boba, this is gonna be good π
β¨ NAME β¨
tntnet β default components for tntnet(8) π«Ά
π DESCRIPTION π
so like, out of the box, tntnet can literally just do one thing: return a http error 404 - not found π. that's it. that's the whole vibe.
to do something meaningful, tntnet loads shared libraries with components. by defining suitable mappings in tntnet.xml(7), tntnet loads those components, which do the actual work. the components are the main characters, fr fr π
and because in the web world there are some really basic tasks that every web server should be able to do, tntnet brings some standard components. the shared library that does all that is called tntnet, and hence every standard component has a component identifier of componentname@tntnet. they are documented right here, no gatekeeping π¦
πΈ static πΈ
the most commonly used standard component is static@tntnet. it gives tntnet the ability to deliver files from the file system. for this it uses the pathinfo 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 mime@tntnet. so iconic β¨
Example
<mapping>
<url>(.*)</url>
<target>static@tntnet</target>
<pathinfo>/var/www/htdocs/$1</pathinfo>
</mapping>
this setting configures tntnet as a simple web server for static pages. serving files? we love to see it π
π mime π
the component mime@tntnet 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. lowkey the backbone of the whole operation π
π empty π
the component empty@tntnet generates just an empty result. by default a http return code OK (200) is set but can be changed with the argument httpcode. other arguments are interpreted as additional http headers, so that e.g. the content type header can be set. empty but make it β¨purposefulβ¨
Example
<mapping>
<url>\.js$</url>
<target>empty@tntnet</target>
<args>
<ContentType>application/javascript</ContentType>
</args>
</mapping>
this tells tntnet to reply all requests with a url ending .js with an empty javascript file. no cap, that's the whole thing π«Ά
π§ unzip π§
the component unzip@tntnet reads static data from a zip file. the file name is read from the argument "file" and the actual file from the path info. it's giving little archive gremlin and we're obsessed π
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.
Example
<mapping>
<url>/thefile/(.*)</url>
<target>unzip@tntnet</target>
<pathinfo>$1</pathinfo>
<args>
<file>/var/www/thefile.zip</file>
</args>
</mapping>
reads file from the specified zip file when the url starts with /thefile/. 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. yes bestie, the typo is canon, we keep it π
β redirect β
the component redirect@tntnet just returns with a redirect to another page. the location for the redirect is specified in the <pathinfo> setting.
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.
Example
<mapping>
<url>^/$</url>
<target>redirect@tntnet</target>
<redirect>/login.html</redirect>
</mapping>
this setting redirects the client to the index.html file when the root directory is requested.
Example for a permanent redirect
<mapping>
<url>^/$</url>
<target>redirect@tntnet</target>
<redirect>/index.html</redirect>
<args>
<type>permanently</type>
</args>
</mapping>
this setting redirects the client to the index.html file when the root directory is requested. (yes, both examples say index.html, even the one with /login.html in it. we don't question the elders π«‘)
π₯ error π₯
the error component returns a specific error code to the client when called. the code is specified using the argument <code> and the message using the argument <message>. the message may be omitted in which case a default error code specific text is used. it's giving "we said no and we meant it" energy π
Example
<mapping>
<method>^POST$</method>
<target>error@tntnet</target>
<args>
<code>405</code>
</args>
</mapping>
this setting prevents tntnet to accept POST message. slay, boundaries β
π AUTHOR π
this manual page was written by Tommi MΓ€kitalo β¨tommi@tntnet.orgβ©. absolute legend, we stan π«Ά
π SEE ALSO π
tntnet-project(1)ecpp(7)ecppc(1)tntnet.xml(7)
and that's the whole page bestie π this was the Tntnet users guide, brought to you by Tntnet on 2013-05-27 β go forth and configure ur mappings, u got this fr fr πβ¨π¦
π¦ where this page comes from
- debian trixie: libtntnet-dev 3.0-4 Β· LGPL-2.1-or-later
- fedora 43: tntnet 1:3.0-14.fc43 Β· LicenseRef-Callaway-LGPLv2+ AND GPL-2.0-or-later AND Zlib
- fedora 43: tntnet 1:3.0-14.fc43 Β· LicenseRef-Callaway-LGPLv2+ AND GPL-2.0-or-later AND Zlib
- fedora 44: tntnet 1:3.0-15.fc44 Β· LicenseRef-Callaway-LGPLv2+ AND GPL-2.0-or-later AND Zlib
- fedora 44: tntnet 1:3.0-15.fc44 Β· LicenseRef-Callaway-LGPLv2+ AND GPL-2.0-or-later AND Zlib
- nixos 26.05: tntnet 3.0
- ubuntu noble: libtntnet-dev 3.0-3.1build1 Β· LGPL-2.1-or-later
- ubuntu questing: libtntnet-dev 3.0-4
- ubuntu resolute: libtntnet-dev 3.0-4build1 Β· LGPL-2.1-or-later
- ubuntu stonking: libtntnet-dev 3.0-4build1 Β· LGPL-2.1-or-later
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms