fix static file serving test

This commit is contained in:
Alp Mestanogullari 2017-01-09 01:02:32 +01:00 committed by Oleg Grenrus
parent 8efabed5c6
commit 0a3b2272de
2 changed files with 4 additions and 2 deletions

View file

@ -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

View file

@ -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 ->