packages feed

servant-proto-lens-0.1.0.0: test/TestClient.hs

module TestClient where

import Servant ((:>)(..), (:<|>)(..))
import qualified Network.HTTP.Client as H
import qualified Proto.Google.Protobuf.Duration as D
import qualified Servant.Client as S

import TestServer (api)

getDur :: S.ClientM D.Duration
exSec :: D.Duration -> S.ClientM Int
exNSec :: D.Duration -> S.ClientM Int

getDur :<|> exSec :<|> exNSec = S.client api

run :: Int -> S.ClientM a -> IO (Either S.ServantError a)
run port action = do
    mgr <- H.newManager H.defaultManagerSettings
    S.runClientM action (S.ClientEnv mgr baseUrl)
    where
        baseUrl = S.BaseUrl S.Http "localhost" port ""