on warp/3.1.10 help sign in
typeable/wai/wai-app-static/test/EmbeddedTestEntries.hs
50 lines 1.6 kB history raw
1{-# LANGUAGE TemplateHaskell, QuasiQuotes, OverloadedStrings #-}
3module EmbeddedTestEntries where
5import WaiAppStatic.Storage.Embedded
6import qualified Data.Text as T
7import qualified Data.Text.Lazy as TL
8import qualified Data.Text.Lazy.Encoding as TL
9import qualified Data.ByteString.Lazy as BL
11body :: Int -> Char -> BL.ByteString
12body i c = TL.encodeUtf8 $ TL.pack $ take i $ repeat c
14mkEntries :: IO [EmbeddableEntry]
15mkEntries = return
16 -- An entry that should be compressed
17 [ EmbeddableEntry "e1.txt"
18 "text/plain"
19 (Left ("Etag 1", body 1000 'A'))
21 -- An entry so short that the compressed text is longer
22 , EmbeddableEntry "e2.txt"
23 "text/plain"
24 (Left ("Etag 2", "ABC"))
26 -- An entry that is not compressed because of the mime
27 , EmbeddableEntry "somedir/e3.txt"
28 "xxx"
29 (Left ("Etag 3", body 1000 'A'))
31 -- A reloadable entry
32 , EmbeddableEntry "e4.css"
33 "text/css"
34 (Right [| return ("Etag 4" :: T.Text, body 2000 'Q') |])
36 -- An entry without etag
37 , EmbeddableEntry "e5.txt"
38 "text/plain"
39 (Left ("", body 1000 'Z'))
41 -- A reloadable entry without etag
42 , EmbeddableEntry "e6.txt"
43 "text/plain"
44 (Right [| return ("" :: T.Text, body 1000 'W') |] )
46 -- An index file
47 , EmbeddableEntry "index.html"
48 "text/html"
49 (Right [| return ("" :: T.Text, "index file") |] )
50 ]