update haskell servant samples

This commit is contained in:
William Cheng
2021-07-13 21:03:07 +08:00
parent 519ab9290e
commit 79866e90cf

View File

@@ -27,6 +27,8 @@ module OpenAPIPetstore.API
, OpenAPIPetstoreClientError(..)
-- ** Servant
, OpenAPIPetstoreAPI
-- ** Plain WAI Application
, serverWaiApplicationOpenAPIPetstore
) where
import OpenAPIPetstore.Types
@@ -284,7 +286,13 @@ runOpenAPIPetstoreMiddlewareServer Config{..} middleware backend = do
let warpSettings = Warp.defaultSettings
& Warp.setPort (baseUrlPort url)
& Warp.setHost (fromString $ baseUrlHost url)
liftIO $ Warp.runSettings warpSettings $ middleware $ serve (Proxy :: Proxy OpenAPIPetstoreAPI) (serverFromBackend backend)
liftIO $ Warp.runSettings warpSettings $ middleware $ serverWaiApplicationOpenAPIPetstore backend
-- | Plain "Network.Wai" Application for the OpenAPIPetstore server.
--
-- Can be used to implement e.g. tests that call the API without a full webserver.
serverWaiApplicationOpenAPIPetstore :: OpenAPIPetstoreBackend (ExceptT ServerError IO) -> Application
serverWaiApplicationOpenAPIPetstore backend = serve (Proxy :: Proxy OpenAPIPetstoreAPI) (serverFromBackend backend)
where
serverFromBackend OpenAPIPetstoreBackend{..} =
(coerce addPet :<|>