Created
January 25, 2014 12:56
-
-
Save prussiap/8615974 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{-# 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