Skip to content

Commit

Permalink
Merge branch '0.9' into master.
Browse files Browse the repository at this point in the history
  • Loading branch information
gregorycollins committed Jun 12, 2012
2 parents 4ed60bc + b95e921 commit bbb7858
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 11 deletions.
2 changes: 1 addition & 1 deletion snap-core.cabal
@@ -1,5 +1,5 @@
name: snap-core
version: 0.8.2
version: 0.9.0
synopsis: Snap: A Haskell Web Framework (core interfaces and types)

description:
Expand Down
10 changes: 5 additions & 5 deletions src/Snap/Util/FileServe.hs
Expand Up @@ -38,8 +38,8 @@ import Data.ByteString.Char8 (ByteString)
import Data.ByteString.Internal (c2w)
import Data.Int
import Data.List
import Data.Map (Map)
import qualified Data.Map as Map
import Data.HashMap.Strict (HashMap)
import qualified Data.HashMap.Strict as Map
import Data.Maybe (fromMaybe, isNothing)
import Data.Monoid
import qualified Data.Text as T
Expand Down Expand Up @@ -79,12 +79,12 @@ getSafePath = do

------------------------------------------------------------------------------
-- | A type alias for dynamic handlers
type HandlerMap m = Map FilePath (FilePath -> m ())
type HandlerMap m = HashMap FilePath (FilePath -> m ())


------------------------------------------------------------------------------
-- | A type alias for MIME type
type MimeMap = Map FilePath ByteString
type MimeMap = HashMap FilePath ByteString


------------------------------------------------------------------------------
Expand Down Expand Up @@ -569,7 +569,7 @@ serveFileAs mime fp = do


------------------------------------------------------------------------------
lookupExt :: a -> Map FilePath a -> FilePath -> a
lookupExt :: a -> HashMap FilePath a -> FilePath -> a
lookupExt def m f =
if null ext
then def
Expand Down
11 changes: 6 additions & 5 deletions test/suite/Snap/Util/FileServe/Tests.hs
Expand Up @@ -12,6 +12,7 @@ import Data.ByteString (ByteString)
import qualified Data.ByteString.Char8 as S
import qualified Data.ByteString.Lazy.Char8 as L
import Data.IORef
import qualified Data.HashMap.Strict as HashMap
import qualified Data.Map as Map
import Data.Maybe
import Data.Monoid
Expand Down Expand Up @@ -313,31 +314,31 @@ cfgA, cfgB, cfgC, cfgD :: DirectoryConfig Snap
cfgA = DirectoryConfig {
indexFiles = []
, indexGenerator = const pass
, dynamicHandlers = Map.empty
, dynamicHandlers = HashMap.empty
, mimeTypes = defaultMimeTypes
, preServeHook = const $ return ()
}

cfgB = DirectoryConfig {
indexFiles = ["index.txt", "altindex.html"]
, indexGenerator = const pass
, dynamicHandlers = Map.empty
, dynamicHandlers = HashMap.empty
, mimeTypes = defaultMimeTypes
, preServeHook = const $ return ()
}

cfgC = DirectoryConfig {
indexFiles = ["index.txt", "altindex.html"]
, indexGenerator = printName
, dynamicHandlers = Map.empty
, dynamicHandlers = HashMap.empty
, mimeTypes = defaultMimeTypes
, preServeHook = const $ return ()
}

cfgD = DirectoryConfig {
indexFiles = []
, indexGenerator = const pass
, dynamicHandlers = Map.fromList [ (".txt", printName) ]
, dynamicHandlers = HashMap.fromList [ (".txt", printName) ]
, mimeTypes = defaultMimeTypes
, preServeHook = const $ return ()
}
Expand Down Expand Up @@ -569,7 +570,7 @@ testRangeBad = testCase "fileServe/range/bad" $ do

------------------------------------------------------------------------------
coverMimeMap :: (Monad m) => m ()
coverMimeMap = Prelude.mapM_ f $ Map.toList defaultMimeTypes
coverMimeMap = Prelude.mapM_ f $ HashMap.toList defaultMimeTypes
where
f (!k,!v) = return $ case k `seq` v `seq` () of () -> ()

Expand Down

0 comments on commit bbb7858

Please sign in to comment.