diff --git a/riotblog.cabal b/riotblog.cabal new file mode 100644 index 0000000..a36d4a8 --- /dev/null +++ b/riotblog.cabal @@ -0,0 +1,30 @@ +Name: riotblog +Version: 0.1 +Synopsis: Project Synopsis Here +Description: Project Description Here +License: AllRightsReserved +Author: Author +Maintainer: maintainer@example.com +Stability: Experimental +Category: Web +Build-type: Simple +Cabal-version: >=1.2 + +Executable riotblog + hs-source-dirs: src + main-is: Main.hs + + Build-depends: + base >= 4 && < 5, + bytestring >= 0.9.1 && < 0.11, + monad-control >= 1.0 && < 1.1, + mtl >= 2 && < 3, + snap-core >= 1.0 && < 1.1, + snap-server >= 1.0 && < 1.1, + ginger + + if impl(ghc >= 6.12.0) + ghc-options: -threaded -Wall -fwarn-tabs -funbox-strict-fields -O2 + -fno-warn-unused-do-bind + else + ghc-options: -threaded -Wall -fwarn-tabs -funbox-strict-fields -O2 diff --git a/src/Main.hs b/src/Main.hs new file mode 100644 index 0000000..0ecb01b --- /dev/null +++ b/src/Main.hs @@ -0,0 +1,24 @@ +{-# LANGUAGE OverloadedStrings #-} +module Main 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! Hey Hey Hey") <|> + route [ ("foo", writeBS "bar") + , ("echo/:echoparam", echoHandler) + ] <|> + dir "static" (serveDirectory ".") + +echoHandler :: Snap () +echoHandler = do + param <- getParam "echoparam" + maybe (writeBS "must specify echo/param in URL") + writeBS param diff --git a/stack.yaml b/stack.yaml new file mode 100644 index 0000000..acd723d --- /dev/null +++ b/stack.yaml @@ -0,0 +1,7 @@ +flags: {} +extra-package-dbs: [] +packages: +- '.' +extra-deps: +- ginger-0.3.7.2 +resolver: lts-7.12