@@ -11,6 +11,9 @@ import Network.Wai.Handler.Warp (withApplication)
1111import Prelude.Compat
1212import Servant (Context (EmptyContext), HasServer,
1313 Server, serveWithContext)
14+#if MIN_VERSION_servant_server(0,18,0)
15+import Servant (DefaultErrorFormatters, ErrorFormatters, HasContextEntry, type (.++))
16+#endif
1417import Servant.Client (BaseUrl (..), Scheme (..))
1518import System.IO.Unsafe (unsafePerformIO)
1619import Test.Hspec (Expectation, expectationFailure)
@@ -37,8 +40,13 @@ withServantServer api = withServantServerAndContext api EmptyContext
3740-- application.
3841--
3942-- /Since 0.0.0.0/
43+#if MIN_VERSION_servant_server(0,18,0)
44+withServantServerAndContext :: (HasServer a ctx, HasContextEntry (ctx .++ DefaultErrorFormatters) ErrorFormatters)
45+ => Proxy a -> Context ctx -> IO (Server a) -> (BaseUrl -> IO r) -> IO r
46+#else
4047withServantServerAndContext :: HasServer a ctx
4148 => Proxy a -> Context ctx -> IO (Server a) -> (BaseUrl -> IO r) -> IO r
49+#endif
4250withServantServerAndContext api ctx server t
4351 = withApplication (return . serveWithContext api ctx =<< server) $ \port ->
4452 t (BaseUrl Http "localhost" port "")