Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Fiddle with servers a little.

--HG--
rename : servers/ping/src/Main.hs => servers/ping/src/Snap.hs
  • Loading branch information...
commit 22722ea5f0400e78033ae36f5ecbd6400a160c5a 1 parent 47470a3
@bos authored
View
16 servers/ping/ping-servers.cabal
@@ -5,13 +5,25 @@ Cabal-version: >=1.2
Executable ping-server-snap
hs-source-dirs: src
- main-is: Main.hs
+ main-is: Snap.hs
Build-depends:
base >= 4 && < 5,
- bytestring >= 0.9.1 && < 0.10,
snap == 0.5.*,
snap-core == 0.5.*,
snap-server == 0.5.*
ghc-options: -rtsopts -threaded -Wall
+
+Executable ping-server-warp
+ hs-source-dirs: src
+ main-is: Warp.hs
+
+ Build-depends:
+ base >= 4 && < 5,
+ blaze-builder >= 0.3.0.1,
+ http-types >= 0.6.5.1,
+ wai >= 0.4.1,
+ warp >= 0.4.2
+
+ ghc-options: -rtsopts -threaded -Wall
View
13 servers/ping/src/Application.hs
@@ -1,13 +0,0 @@
-module Application
- ( Application
- , applicationInitializer
- ) where
-
-import Snap.Extension
-
-type Application = SnapExtend ApplicationState
-
-type ApplicationState = ()
-
-applicationInitializer :: Initializer ApplicationState
-applicationInitializer = return ()
View
6 servers/ping/src/Main.hs
@@ -1,6 +0,0 @@
-import Snap.Extension.Server
-import Application
-import Site
-
-main :: IO ()
-main = quickHttpServe applicationInitializer site
View
8 servers/ping/src/Site.hs
@@ -1,8 +0,0 @@
-{-# LANGUAGE OverloadedStrings #-}
-
-module Site (site) where
-
-import Application
-
-site :: Application ()
-site = return ()
View
15 servers/ping/src/Snap.hs
@@ -0,0 +1,15 @@
+{-# LANGUAGE OverloadedStrings #-}
+import Snap.Http.Server (httpServe)
+import Snap.Http.Server.Config (defaultConfig, setAccessLog, setErrorLog, setPort)
+import Snap.Types (Snap, writeBS)
+
+site :: Snap ()
+site = writeBS "PONG"
+
+main :: IO ()
+main = do
+ let config = setPort 8000 .
+ setAccessLog Nothing .
+ setErrorLog Nothing $
+ defaultConfig
+ httpServe config site
View
11 servers/ping/src/Warp.hs
@@ -0,0 +1,11 @@
+{-# LANGUAGE OverloadedStrings #-}
+import Blaze.ByteString.Builder (fromByteString)
+import Network.HTTP.Types (status200)
+import Network.Wai (Response(ResponseBuilder))
+import Network.Wai.Handler.Warp (run)
+
+main :: IO ()
+main = run 8000 $ const $ return $ ResponseBuilder
+ status200
+ [("Content-Type", "text/plain"), ("Content-Length", "4")]
+ $ fromByteString "PONG"
Please sign in to comment.
Something went wrong with that request. Please try again.