Last active
August 29, 2015 14:04
-
-
Save phylake/4999ea9b5da8e28a9108 to your computer and use it in GitHub Desktop.
"hello world" warp app
This file contains hidden or 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
-- warp-2.1.5.2 | |
-- ghc -O2 -threaded -rtsopts warp | |
-- ./warp +RTS -N -A1G | |
{-# LANGUAGE OverloadedStrings #-} | |
module Main where | |
import Blaze.ByteString.Builder (copyByteString) | |
import Data.Text (unpack) | |
import Network.HTTP.Types.Status (status200) | |
import Network.Wai | |
import Network.Wai.Handler.Warp (run) | |
main :: IO () | |
main = do | |
putStrLn "starting simple HTTP" | |
run 3001 app | |
app :: Application | |
app req = do | |
--p $ show $ rawPathInfo req | |
case map unpack (pathInfo req) of | |
_ -> do | |
s200 | |
s200 :: IO Response | |
s200 = return | |
$ responseBuilder status200 [("Content-Type", "text/plain")] | |
$ copyByteString "PONG" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment