Support servant-server-0.18
This commit is contained in:
parent
7926ad6bdb
commit
e6daf03c16
@ -1,2 +1,4 @@
|
|||||||
packages: .
|
packages: .
|
||||||
tests: true
|
tests: true
|
||||||
|
|
||||||
|
allow-newer: servant-blaze:servant
|
||||||
|
|||||||
@ -49,9 +49,9 @@ library
|
|||||||
, pretty >=1.1 && <1.2
|
, pretty >=1.1 && <1.2
|
||||||
, process >=1.2 && <1.7
|
, process >=1.2 && <1.7
|
||||||
, QuickCheck >=2.7 && <2.15
|
, QuickCheck >=2.7 && <2.15
|
||||||
, servant >=0.17 && <0.18
|
, servant >=0.17 && <0.19
|
||||||
, servant-client >=0.17 && <0.18
|
, servant-client >=0.17 && <0.19
|
||||||
, servant-server >=0.17 && <0.18
|
, servant-server >=0.17 && <0.19
|
||||||
, split >=0.2 && <0.3
|
, split >=0.2 && <0.3
|
||||||
, string-conversions >=0.3 && <0.5
|
, string-conversions >=0.3 && <0.5
|
||||||
, temporary >=1.2 && <1.4
|
, temporary >=1.2 && <1.4
|
||||||
|
|||||||
@ -11,6 +11,9 @@ import Network.Wai.Handler.Warp (withApplication)
|
|||||||
import Prelude.Compat
|
import Prelude.Compat
|
||||||
import Servant (Context (EmptyContext), HasServer,
|
import Servant (Context (EmptyContext), HasServer,
|
||||||
Server, serveWithContext)
|
Server, serveWithContext)
|
||||||
|
#if MIN_VERSION_servant_server(0,18,0)
|
||||||
|
import Servant (DefaultErrorFormatters, ErrorFormatters, HasContextEntry, type (.++))
|
||||||
|
#endif
|
||||||
import Servant.Client (BaseUrl (..), Scheme (..))
|
import Servant.Client (BaseUrl (..), Scheme (..))
|
||||||
import System.IO.Unsafe (unsafePerformIO)
|
import System.IO.Unsafe (unsafePerformIO)
|
||||||
import Test.Hspec (Expectation, expectationFailure)
|
import Test.Hspec (Expectation, expectationFailure)
|
||||||
@ -37,8 +40,13 @@ withServantServer api = withServantServerAndContext api EmptyContext
|
|||||||
-- application.
|
-- application.
|
||||||
--
|
--
|
||||||
-- /Since 0.0.0.0/
|
-- /Since 0.0.0.0/
|
||||||
|
#if MIN_VERSION_servant_server(0,18,0)
|
||||||
|
withServantServerAndContext :: (HasServer a ctx, HasContextEntry (ctx .++ DefaultErrorFormatters) ErrorFormatters)
|
||||||
|
=> Proxy a -> Context ctx -> IO (Server a) -> (BaseUrl -> IO r) -> IO r
|
||||||
|
#else
|
||||||
withServantServerAndContext :: HasServer a ctx
|
withServantServerAndContext :: HasServer a ctx
|
||||||
=> Proxy a -> Context ctx -> IO (Server a) -> (BaseUrl -> IO r) -> IO r
|
=> Proxy a -> Context ctx -> IO (Server a) -> (BaseUrl -> IO r) -> IO r
|
||||||
|
#endif
|
||||||
withServantServerAndContext api ctx server t
|
withServantServerAndContext api ctx server t
|
||||||
= withApplication (return . serveWithContext api ctx =<< server) $ \port ->
|
= withApplication (return . serveWithContext api ctx =<< server) $ \port ->
|
||||||
t (BaseUrl Http "localhost" port "")
|
t (BaseUrl Http "localhost" port "")
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user