servant/servant-client/test/ghcjs/testServer.hs
Sönke Hahn 2434399845 wip
2016-04-06 16:58:44 +08:00

28 lines
783 B
Haskell

{-# LANGUAGE DataKinds #-}
{-# LANGUAGE TypeOperators #-}
import Network.Wai.Handler.Warp
import Servant
import System.IO
import Servant.Client.TestServer.GHC
import Servant.Client.TestServer.Types
import Servant.ClientSpec
main :: IO ()
main = do
(port, socket) <- openTestSocket
let settings =
setPort port $
setBeforeMainLoop (print port >> hFlush stdout) $
defaultSettings
runSettingsSocket settings socket $
serve testServerApi $ \ testServerName request respond -> do
app <- testServerApp <$> lookupTestServer testServerName
app request respond
type TestServerApi =
Capture "testServerName" String :> Raw
testServerApi :: Proxy TestServerApi
testServerApi = Proxy