happs-tutorial-0.8: templates/basicurlhandling.st
<h3>Basic Request Handling in Happstack</h3>
<p>One of the most basic functions of a web framework is to give you a way of controlling what happens when a web browser makes an http request.</p>
<p>Let's look at some simple examples.</p>
<ol>
<li> Read the source code of the simpleHandlers function in <a href="/src/ControllerBasic.hs">ControllerBasic.hs</a> to see how urls are handled in Happstack. <b>The comments contain the bulk of the information in this chapter.</b></li>
<li>Follow the urls below by clicking on them. Match what happens when you click on a link with the code in <a href="/src/ControllerBasic.hs">ControllerBasic.hs</a>.</li>
<ul>
<li>introduction to handlers: <a href="/helloworld">hello world</a></li>
<li>exactdir (subdirectories of the path argument do not match):
<a href="/exactdir">exactdir</a> ...
<a href="/exactdir/subdir">exactdir/subdir</a> ...
</li>
<li>introduction to dir -- subdirectories *do* match:
<a href="/dir">dir</a> ...
<a href="/dir/subdir">dir/subdir</a>
</li>
<li>gluing handlers together / handlers as monoids:
<a href="/handleraddition1">handleraddition1</a> ...
<a href="/handleraddition2">handleraddition2</a> ...
<a href="/handleraddition3">handleraddition3</a> ...
<a href="/handleraddition4">handleraddition4</a> ...
<a href="/handleraddition5">handleraddition5</a>
</li>
<li>the "empty" handler:
<a href="/nohandle1">nohandle1</a>
</li>
<li>IO in the response: <a href="/ioaction">IO Response</a> ...
<a href="/ioaction2">Another IO Response</a
</li>
<li>Formatted html: <a href="/htmlAttemptWrong">First attempt at formatted html (wrong)</a> </li>
<li><a href="/htmlAttemptRight">Second attempt at formatted html (right)</a></li>
<li><a href="/htmlAttemptForeignChars">Foreign characters in formatted html</a></li>
<li>Serving static files: <a href="/templates/base.st">Using dir and fileserve "templates", we can view templates</a> ...
<a href="/templates/basicurlhandling.st">The template that was used to generate this page</a>
</li>
<li><a href="/redirect">redirection with seeOther</a></li>
</ul>
</ol>
<p>The static file serving example above hints at the templating system used by this tutorial to put together web pages behind the scenes.</p>
<p>We learn about ways to conveniently include HTML <a href="/tutorial/basic-html">next.</a></p>