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 17:59:28 +01:00
|
|
|
serve testServerApi $
|
|
|
|
testServerApp server :<|>
|
|
|
|
testServerApp errorServer :<|>
|
|
|
|
testServerApp failServer
|
2015-11-25 10:31:58 +01:00
|
|
|
|
|
|
|
type TestServerApi =
|
|
|
|
"server" :> Raw :<|>
|
|
|
|
"errorServer" :> Raw :<|>
|
|
|
|
"failServer" :> Raw
|
|
|
|
|
|
|
|
testServerApi :: Proxy TestServerApi
|
|
|
|
testServerApi = Proxy
|