wai-middleware-content-type 0.1.1 → 0.1.1.1
raw patch · 3 files changed
+14/−4 lines, 3 filesPVP ok
version bump matches the API change (PVP)
API changes (from Hackage documentation)
Files
- src/Network/Wai/Middleware/ContentType.hs +6/−3
- src/Network/Wai/Middleware/ContentType/Types.hs +7/−0
- wai-middleware-content-type.cabal +1/−1
src/Network/Wai/Middleware/ContentType.hs view
@@ -98,8 +98,10 @@ mMiddleware <- lookupResponse mAcceptBS mFe contentRoutes fromMaybe (app req respond) $ do mid <- mMiddleware- return $ mid app req respond+ pure (mid app req respond) +{-# INLINEABLE fileExtsToMiddleware #-}+ -- | Given an HTTP @Accept@ header and a content type to base lookups off of, and -- a map of responses, find a response. lookupResponse :: ( MonadIO m@@ -120,6 +122,7 @@ Nothing -> xs Just fe -> fe <$ guard (fe `elem` xs) +{-# INLINEABLE lookupResponse #-} -- | Takes an @Accept@ header and returns the other -- file types handleable, in order of prescedence.@@ -145,7 +148,7 @@ wildcard = fromMaybe [] $ mapAccept [ ("*/*" :: BS.ByteString, allFileExts) ] accept -+{-# INLINEABLE possibleFileExts #-} -- | Use this combinator as the last one, as a "catch-all": --@@ -155,4 +158,4 @@ invalidEncoding :: MonadIO m => MiddlewareT m -> FileExtListenerT (MiddlewareT m) m () invalidEncoding mid = mapM_ (`middleware` mid) allFileExts -+{-# INLINEABLE invalidEncoding #-}
src/Network/Wai/Middleware/ContentType/Types.hs view
@@ -78,6 +78,7 @@ allFileExts :: [FileExt] allFileExts = [Html,Text,Json,JavaScript,Css,Markdown] +{-# INLINEABLE allFileExts #-} -- | Gets the known file extension from a Request's 'Network.Wai.pathInfo'. getFileExt :: [T.Text] -> Maybe FileExt@@ -85,6 +86,8 @@ [] -> Nothing xs -> toExt . snd . T.breakOn "." $ last xs +{-# INLINEABLE getFileExt #-}+ -- | matches a file extension (__including__ it's prefix dot - @.html@ for example) -- to a known one. toExt :: T.Text -> Maybe FileExt@@ -103,6 +106,8 @@ texts = [".txt"] markdowns = [".md", ".markdown"] +{-# INLINEABLE toExt #-}+ type FileExtMap a = HashMap FileExt a -- | The monad for our DSL - when using the combinators, our result will be this@@ -136,3 +141,5 @@ execFileExtListenerT :: Monad m => FileExtListenerT r m a -> m (FileExtMap r) execFileExtListenerT xs = execStateT (runFileExtListenerT xs) mempty++{-# INLINEABLE execFileExtListenerT #-}
wai-middleware-content-type.cabal view
@@ -1,5 +1,5 @@ Name: wai-middleware-content-type-Version: 0.1.1+Version: 0.1.1.1 Author: Athan Clark <athan.clark@gmail.com> Maintainer: Athan Clark <athan.clark@gmail.com> License: BSD3