git.iko.soy/typeable/servant
on master help sign in
Merge pull request #82 from triplepointfive/drop-system-filepath

Add support for wai-app-static-3.1.0

commit763928cd66ca81a09cd90a869b90e9ff62056f53 authorJulian Arni <jkarni@gmail.com> dateMon 18 May 2015, 12:55 (11 years ago) parent09e525f7e14eea
2 files changed+13−4
servant-server/servant-server.cabal+2−1 servant-server/src/Servant/Utils/StaticFiles.hs+11−3
servant-server/servant-server.cabal+2−1
@@ -53,10 +53,11 @@ library
5353 , split >= 0.2 && < 0.3
5454 , string-conversions >= 0.3 && < 0.4
5555 , system-filepath >= 0.4 && < 0.5
56+ , filepath >= 1
5657 , text >= 1.2 && < 1.3
5758 , transformers >= 0.3 && < 0.5
5859 , wai >= 3.0 && < 3.1
59− , wai-app-static >= 3.0 && < 3.1
60+ , wai-app-static >= 3.0 && < 3.2
6061 , warp >= 3.0 && < 3.1
6162 hs-source-dirs: src
6263 default-language: Haskell2010
servant-server/src/Servant/Utils/StaticFiles.hs+11−3
@@ -1,3 +1,4 @@
1+{-# LANGUAGE CPP #-}
12-- | This module defines a sever-side handler that lets you serve static files.
23--
34-- - 'serveDirectory' lets you serve anything that lives under a particular
@@ -6,10 +7,13 @@ module Servant.Utils.StaticFiles (
67 serveDirectory,
78 ) where
89
9−import Filesystem.Path.CurrentOS (decodeString)
10+import System.FilePath (addTrailingPathSeparator)
1011import Network.Wai.Application.Static (staticApp, defaultFileServerSettings)
1112import Servant.API.Raw (Raw)
1213import Servant.Server (Server)
14+#if !MIN_VERSION_wai_app_static(3,1,0)
15+import Filesystem.Path.CurrentOS (decodeString)
16+#endif
1317
1418-- | Serve anything under the specified directory as a 'Raw' endpoint.
1519--
@@ -32,5 +36,9 @@ import Servant.Server (Server)
3236-- handler in the last position, because /servant/ will try to match the handlers
3337-- in order.
3438serveDirectory :: FilePath -> Server Raw
35−serveDirectory documentRoot =
36− staticApp (defaultFileServerSettings (decodeString (documentRoot ++ "/")))
39+serveDirectory =
40+#if MIN_VERSION_wai_app_static(3,1,0)
41+ staticApp . defaultFileServerSettings . addTrailingPathSeparator
42+#else
43+ staticApp . defaultFileServerSettings . decodeString . addTrailingPathSeparator
44+#endif