add unRaw and remove id from StaticFiles.hs
This commit is contained in:
parent
8052d61c50
commit
1b7e608f29
3 changed files with 20 additions and 5 deletions
|
@ -43,9 +43,7 @@ serveDirectoryWith settings = Raw (staticApp settings)
|
|||
|
||||
serveDirectory :: FilePath -> ServerT (Raw Application m) n
|
||||
serveDirectory = serveDirectoryWith . defaultFileServerSettings .
|
||||
#if MIN_VERSION_wai_app_static(3,1,0)
|
||||
id .
|
||||
#else
|
||||
#if !MIN_VERSION_wai_app_static(3,1,0)
|
||||
decodeString .
|
||||
#endif
|
||||
addTrailingPathSeparator
|
||||
|
|
|
@ -12,5 +12,7 @@ import Data.Typeable (Typeable)
|
|||
-- In addition to just letting you plug in your existing WAI 'Application's,
|
||||
-- this can also be used with 'Servant.Utils.StaticFiles.serveDirectory' to serve
|
||||
-- static files stored in a particular directory on your filesystem
|
||||
newtype Raw a (m :: * -> *) = Raw a
|
||||
deriving Typeable
|
||||
newtype Raw a (m :: * -> *) = Raw {
|
||||
unRaw :: a
|
||||
}
|
||||
deriving (Eq, Show, Typeable)
|
||||
|
|
15
servant/test/Servant/API/RawSpec.hs
Normal file
15
servant/test/Servant/API/RawSpec.hs
Normal file
|
@ -0,0 +1,15 @@
|
|||
{-# LANGUAGE DataKinds #-}
|
||||
{-# LANGUAGE OverloadedStrings #-}
|
||||
module Servant.API.RawSpec where
|
||||
|
||||
import Test.Hspec
|
||||
|
||||
import Servant.API.Raw
|
||||
|
||||
spec :: Spec
|
||||
spec = describe "Servant.API.Raw" $ do
|
||||
describe "unRaw" $ do
|
||||
it "unRaw returns proper value" $ do
|
||||
let p = Raw "testing" :: Raw String IO
|
||||
p `shouldBe` (Raw "testing")
|
||||
(unRaw p) `shouldBe` "testing"
|
Loading…
Reference in a new issue