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

29 lines
783 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-04-06 10:58:44 +02:00
serve testServerApi $ \ testServerName request respond -> do
app <- testServerApp <$> lookupTestServer testServerName
app request respond
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