servant/servant-client/test/ghcjs/testServer.hs

28 lines
729 B
Haskell
Raw Normal View History

2015-11-25 10:31:58 +01:00
{-# LANGUAGE DataKinds #-}
{-# LANGUAGE TypeOperators #-}
import Network.Wai.Handler.Warp
import Servant
import System.IO
import Servant.Client.TestServer.GHC
2016-01-04 17:59:28 +01:00
import Servant.Client.TestServer.Types
2015-11-25 10:31:58 +01:00
import Servant.ClientSpec
main :: IO ()
main = do
(port, socket) <- openTestSocket
let settings =
setPort port $
setBeforeMainLoop (print port >> hFlush stdout) $
defaultSettings
runSettingsSocket settings socket $
2016-01-04 19:04:10 +01:00
serve testServerApi $ \ testServerName ->
testServerApp $ lookupTestServer testServerName
2015-11-25 10:31:58 +01:00
type TestServerApi =
2016-01-04 19:04:10 +01:00
Capture "testServerName" String :> Raw
2015-11-25 10:31:58 +01:00
testServerApi :: Proxy TestServerApi
testServerApi = Proxy