Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Minor code formatting issues

  • Loading branch information...
commit d5bdfdca796560e9d217803db9719ef2e80c022a 1 parent c08f985
@gregorycollins gregorycollins authored
Showing with 12 additions and 12 deletions.
  1. +12 −12 snaplets/heist/templates/docs/tutorials/snap-api.md
View
24 snaplets/heist/templates/docs/tutorials/snap-api.md
@@ -54,29 +54,29 @@ echoHandler = do
The behavior of this code can be summarized with the following rules:
-1. If the user requested the site's root page (http://mysite.com/), then
-return a page containing the string "hello world".
-2. If the user requested /foo, then return "bar".
-3. If the user requested /echo/xyz, then return "xyz".
-4. If the request URL begins with /static/, then look for files on disk
+1. If the user requested the site's root page (`http://mysite.com/`), then
+return a page containing the string `"hello world"`.
+2. If the user requested `/foo`, then return `"bar"`.
+3. If the user requested `/echo/xyz`, then return `"xyz"`.
+4. If the request URL begins with `/static/`, then look for files on disk
matching the rest of the path and serve them.
5. If none of these match, then Snap returns a 404 page.
Let's go over each of the Snap API functions used here.
-### [`dir`](http://hackage.haskell.org/packages/archive/snap-core/0.8.0/doc/html/Snap-Core.html#v:dir)
+### [`dir`](http://hackage.haskell.org/packages/archive/snap-core/0.9.0/doc/html/Snap-Core.html#v:dir)
`dir` runs its action only if the request path starts with the specified
directory. You can combine successive dir calls to match more than one
subdirectory into the path.
-### [`ifTop`](http://hackage.haskell.org/packages/archive/snap-core/0.8.0/doc/html/Snap-Core.html#v:ifTop)
+### [`ifTop`](http://hackage.haskell.org/packages/archive/snap-core/0.9.0/doc/html/Snap-Core.html#v:ifTop)
`ifTop` only executes its argument if the client requested the root URL. Use
this for your home page. It can also be combined with the `dir` function to
define your index handler for a certain URL directory.
-### [`writeBS`](http://hackage.haskell.org/packages/archive/snap-core/0.8.0/doc/html/Snap-Core.html#v:writeBS)
+### [`writeBS`](http://hackage.haskell.org/packages/archive/snap-core/0.9.0/doc/html/Snap-Core.html#v:writeBS)
`writeBS` appends a strict ByteString to the response being constructed. Snap
also provides an analogous function `writeLBS` for lazy ByteStrings. You can
@@ -101,21 +101,21 @@ your site. For large sites, this could be quite noticeable. To remedy this,
Snap also provides you with the `route` function that routes requests based on the
request path in `O(log n)` time:
-### [`route`](http://hackage.haskell.org/packages/archive/snap-core/0.8.0/doc/html/Snap-Core.html#v:route)
+### [`route`](http://hackage.haskell.org/packages/archive/snap-core/0.9.0/doc/html/Snap-Core.html#v:route)
`route` takes a list of (route, handler) tuples and succeeds returning the
result of the associated handler of the route that matches. If no route
-matches, then `route` fails and execution is passed on to `serveDirectory`.
+matches, then `route` fails and execution is passed on to `serveDirectory`.
In a real application, you will want to use `route` for almost everything.
We didn't do it that way in this example because we wanted to demonstrate
more of the API.
-### [`getParam`](http://hackage.haskell.org/packages/archive/snap-core/0.8.0/doc/html/Snap-Core.html#v:getParam)
+### [`getParam`](http://hackage.haskell.org/packages/archive/snap-core/0.9.0/doc/html/Snap-Core.html#v:getParam)
`getParam` retrieves a GET or POST parameter from the request. In this
example, the `route` function binds a captured portion of the URL to the
-parameter `echoParam` so the associated handler can make easy use of it.
+parameter `echoParam` so the associated handler can make easy use of it.
`echoHandler` checks to see whether a parameter was passed and returns the
value or an error message if it didn't exist.
Please sign in to comment.
Something went wrong with that request. Please try again.