Skip to content

Commit

Permalink
update haskell servant samples
Browse files Browse the repository at this point in the history
  • Loading branch information
wing328 committed Jul 13, 2021
1 parent 519ab92 commit 79866e9
Showing 1 changed file with 9 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ module OpenAPIPetstore.API
, OpenAPIPetstoreClientError(..)
-- ** Servant
, OpenAPIPetstoreAPI
-- ** Plain WAI Application
, serverWaiApplicationOpenAPIPetstore
) where

import OpenAPIPetstore.Types
Expand Down Expand Up @@ -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 :<|>
Expand Down

0 comments on commit 79866e9

Please sign in to comment.