From 0a3b2272debe4e6c09c5d5eb5a7c3937ee275c19 Mon Sep 17 00:00:00 2001 From: Alp Mestanogullari Date: Mon, 9 Jan 2017 01:02:32 +0100 Subject: [PATCH] fix static file serving test --- servant-server/src/Servant/Utils/StaticFiles.hs | 2 ++ servant-server/test/Servant/Utils/StaticFilesSpec.hs | 4 ++-- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/servant-server/src/Servant/Utils/StaticFiles.hs b/servant-server/src/Servant/Utils/StaticFiles.hs index 30485c74..ec1630e6 100644 --- a/servant-server/src/Servant/Utils/StaticFiles.hs +++ b/servant-server/src/Servant/Utils/StaticFiles.hs @@ -49,6 +49,8 @@ serveDirectoryWebApp :: FilePath -> Server Raw serveDirectoryWebApp = staticApp . defaultWebAppSettings . fixPath -- | Same as 'serveDirectoryWebApp', but uses `defaultFileServerSettings`. +-- +-- This used to be called 'serveDirectory' in @servant < 0.10@. serveDirectoryFileServer :: FilePath -> Server Raw serveDirectoryFileServer = staticApp . defaultFileServerSettings . fixPath diff --git a/servant-server/test/Servant/Utils/StaticFilesSpec.hs b/servant-server/test/Servant/Utils/StaticFilesSpec.hs index 94c63f18..b3c43d31 100644 --- a/servant-server/test/Servant/Utils/StaticFilesSpec.hs +++ b/servant-server/test/Servant/Utils/StaticFilesSpec.hs @@ -18,7 +18,7 @@ import Test.Hspec.Wai (get, shouldRespondWith, with) import Servant.API ((:<|>) ((:<|>)), Capture, Get, Raw, (:>), JSON) import Servant.Server (Server, serve) import Servant.ServerSpec (Person (Person)) -import Servant.Utils.StaticFiles (serveDirectory) +import Servant.Utils.StaticFiles (serveDirectoryFileServer) type Api = "dummy_api" :> Capture "person_name" String :> Get '[JSON] Person @@ -34,7 +34,7 @@ app = serve api server server :: Server Api server = (\ name_ -> return (Person name_ 42)) - :<|> serveDirectory "static" + :<|> serveDirectoryFileServer "static" withStaticFiles :: IO () -> IO () withStaticFiles action = withSystemTempDirectory "servant-test" $ \ tmpDir ->