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/ 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..2785b66 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.10 , http-types , text , time diff --git a/test/Servant/EkgSpec.hs b/test/Servant/EkgSpec.hs index 5831625..c7b214d 100644 --- a/test/Servant/EkgSpec.hs +++ b/test/Servant/EkgSpec.hs @@ -1,6 +1,6 @@ +{-# LANGUAGE CPP #-} {-# LANGUAGE DataKinds #-} {-# LANGUAGE DeriveGeneric #-} -{-# LANGUAGE OverlappingInstances #-} {-# LANGUAGE OverloadedStrings #-} {-# LANGUAGE PolyKinds #-} {-# LANGUAGE TypeFamilies #-} @@ -9,7 +9,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 @@ -39,7 +41,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" @@ -69,7 +75,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 +99,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.