Skip to content

Instantly share code, notes, and snippets.

@prussiap
Created January 25, 2014 12:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save prussiap/8615974 to your computer and use it in GitHub Desktop.
Save prussiap/8615974 to your computer and use it in GitHub Desktop.
{-# LANGUAGE OverloadedStrings #-}
module FreightyCat where
import Control.Applicative
import Snap.Core
import Snap.Util.FileServe
import Snap.Http.Server
main :: IO ()
main = quickHttpServe site
site :: Snap ()
site =
ifTop (writeBS "hello world") <|>
route [ ("foo", writeBS "bar")
, ("echo/:echoparam", echoHandler)
, ("blah/:user", blahHandler)
] <|>
dir "static" (serveDirectory ".")
echoHandler :: Snap ()
echoHandler = do
param <- getParam "echoparam"
maybe (writeBS "must specify echo/param in URL")
writeBS param
blahHandler :: Snap ()
blahHandler = do
user <- getParam "user"
maybe (writeBS "must specify echo/param in URL")
writeBS user
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment