From 03ac1abd307cd18f36391f6fbaefbe52ba7f9bd0 Mon Sep 17 00:00:00 2001 From: Martin Heuschober Date: Mon, 30 Jan 2017 02:11:58 +0100 Subject: [PATCH 1/4] add .stack-work to gitignore --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index 08b3fb3..6d83ecb 100644 --- a/.gitignore +++ b/.gitignore @@ -3,3 +3,4 @@ .cabal-sandbox/* *dist/ *dist-newstyle/ +.stack-work/ From 9d7fe71bf600e6ec9c44a36b2caf7e583f82c55e Mon Sep 17 00:00:00 2001 From: Martin Heuschober Date: Mon, 30 Jan 2017 02:32:24 +0100 Subject: [PATCH 2/4] compatibility servant 0.8.x - add HasEndpoint instance for `CaptureAll` - adjust test case for Delete () => NoContent - adjust upper bounds for base & servant --- lib/Servant/Ekg.hs | 6 ++++++ servant-ekg.cabal | 4 ++-- test/Servant/EkgSpec.hs | 9 +++++++++ 3 files changed, 17 insertions(+), 2 deletions(-) diff --git a/lib/Servant/Ekg.hs b/lib/Servant/Ekg.hs index e08b736..3e4164a 100644 --- a/lib/Servant/Ekg.hs +++ b/lib/Servant/Ekg.hs @@ -1,3 +1,4 @@ +{-# LANGUAGE CPP #-} {-# LANGUAGE DataKinds #-} {-# LANGUAGE FlexibleContexts #-} {-# LANGUAGE FlexibleInstances #-} @@ -160,3 +161,8 @@ instance ReflectMethod method => HasEndpoint (Verb method status cts a) where instance HasEndpoint (Raw) where getEndpoint _ _ = Just ([],"RAW") + +#if MIN_VERSION_servant(0,8,1) +instance HasEndpoint (sub :: *) => HasEndpoint (CaptureAll (h :: Symbol) a :> sub) where + getEndpoint _ = getEndpoint (Proxy :: Proxy sub) +#endif diff --git a/servant-ekg.cabal b/servant-ekg.cabal index f22138f..f57d037 100644 --- a/servant-ekg.cabal +++ b/servant-ekg.cabal @@ -17,9 +17,9 @@ source-repository HEAD library exposed-modules: Servant.Ekg hs-source-dirs: lib - build-depends: base >=4.7 && <4.9 + build-depends: base >=4.7 && < 4.10 , ekg-core - , servant > 0.5 && < 0.8 + , servant > 0.5 && < 0.9 , http-types , text , time diff --git a/test/Servant/EkgSpec.hs b/test/Servant/EkgSpec.hs index 5831625..5ee2f2b 100644 --- a/test/Servant/EkgSpec.hs +++ b/test/Servant/EkgSpec.hs @@ -1,3 +1,4 @@ +{-# LANGUAGE CPP #-} {-# LANGUAGE DataKinds #-} {-# LANGUAGE DeriveGeneric #-} {-# LANGUAGE OverlappingInstances #-} @@ -69,7 +70,11 @@ type TestApi = :<|> "greet" :> ReqBody '[JSON] Greet :> Post '[JSON] Greet -- DELETE /greet/:greetid +#if MIN_VERSION_servant(0,8,0) + :<|> "greet" :> Capture "greetid" Text :> Delete '[JSON] NoContent +#else :<|> "greet" :> Capture "greetid" Text :> Delete '[JSON] () +#endif testApi :: Proxy TestApi testApi = Proxy @@ -89,7 +94,11 @@ server = helloH :<|> postGreetH :<|> deleteGreetH postGreetH = return +#if MIN_VERSION_servant(0,8,0) + deleteGreetH _ = return NoContent +#else deleteGreetH _ = return () +#endif -- Turn the server into a WAI app. 'serve' is provided by servant, -- more precisely by the Servant.Server module. From c99f3005c8c92462b352c0e2eaaf55c0d06ebd37 Mon Sep 17 00:00:00 2001 From: Martin Heuschober Date: Mon, 30 Jan 2017 03:00:58 +0100 Subject: [PATCH 3/4] compatibility servant 0.9 --- servant-ekg.cabal | 2 +- test/Servant/EkgSpec.hs | 6 ++++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/servant-ekg.cabal b/servant-ekg.cabal index f57d037..2785b66 100644 --- a/servant-ekg.cabal +++ b/servant-ekg.cabal @@ -19,7 +19,7 @@ library hs-source-dirs: lib build-depends: base >=4.7 && < 4.10 , ekg-core - , servant > 0.5 && < 0.9 + , servant > 0.5 && < 0.10 , http-types , text , time diff --git a/test/Servant/EkgSpec.hs b/test/Servant/EkgSpec.hs index 5ee2f2b..54f5538 100644 --- a/test/Servant/EkgSpec.hs +++ b/test/Servant/EkgSpec.hs @@ -10,7 +10,9 @@ module Servant.EkgSpec (spec) where import Control.Concurrent +#if !MIN_VERSION_servant(0,9,0) import Control.Monad.Trans.Except +#endif import Data.Aeson import Data.Monoid import Data.Proxy @@ -40,7 +42,11 @@ spec = describe "servant-ekg" $ do it "collects number of request" $ do withApp $ \port mvar -> do mgr <- newManager defaultManagerSettings +#if MIN_VERSION_servant(0,9,0) + Right _result <- runClientM (getEp "name" Nothing) (ClientEnv mgr (BaseUrl Http "localhost" port "")) +#else _result <- runExceptT $ getEp "name" Nothing mgr (BaseUrl Http "localhost" port "") +#endif m <- readMVar mvar case H.lookup "hello.:name.GET" m of Nothing -> fail "Expected some value" From 5cdc722b3aa5986ab706ca6e59dcc8e759be1208 Mon Sep 17 00:00:00 2001 From: Martin Heuschober Date: Mon, 30 Jan 2017 03:06:13 +0100 Subject: [PATCH 4/4] cleanup: removed unused (deprecated) language pragma --- test/Servant/EkgSpec.hs | 1 - 1 file changed, 1 deletion(-) diff --git a/test/Servant/EkgSpec.hs b/test/Servant/EkgSpec.hs index 54f5538..c7b214d 100644 --- a/test/Servant/EkgSpec.hs +++ b/test/Servant/EkgSpec.hs @@ -1,7 +1,6 @@ {-# LANGUAGE CPP #-} {-# LANGUAGE DataKinds #-} {-# LANGUAGE DeriveGeneric #-} -{-# LANGUAGE OverlappingInstances #-} {-# LANGUAGE OverloadedStrings #-} {-# LANGUAGE PolyKinds #-} {-# LANGUAGE TypeFamilies #-}