Skip to content

Instantly share code, notes, and snippets.

@phylake
Last active August 29, 2015 14:04
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 phylake/4999ea9b5da8e28a9108 to your computer and use it in GitHub Desktop.
Save phylake/4999ea9b5da8e28a9108 to your computer and use it in GitHub Desktop.
"hello world" warp app
-- 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