packages feed

apiary 0.17.1 → 0.17.2

raw patch · 3 files changed

+25/−6 lines, 3 filesdep +http-datedep +unix-compatPVP: major bump suggested

API removals or changes: PVP suggests a major version bump

Dependencies added: http-date, unix-compat

API changes (from Hackage documentation)

- Control.Monad.Apiary.Action: file :: Monad m => FilePath -> Maybe FilePart -> ActionT exts m ()
+ Control.Monad.Apiary.Action: file :: MonadIO m => FilePath -> Maybe FilePart -> ActionT exts m ()
- Control.Monad.Apiary.Action: file' :: Monad m => FilePath -> Maybe FilePart -> ActionT exts m ()
+ Control.Monad.Apiary.Action: file' :: MonadIO m => FilePath -> Maybe FilePart -> ActionT exts m ()

Files

CHANGELOG.md view
@@ -1,3 +1,6 @@+# 0.17.2+* send 302 if file not midified.+ # 0.17.1 * relax switchQuery. 
apiary.cabal view
@@ -1,5 +1,5 @@ name:                apiary-version:             0.17.1+version:             0.17.2 synopsis:            Simple and type safe web framework that can be automatically generate API documentation. description:   Simple and type safe web framework that can be automatically generate API documentation.@@ -116,6 +116,8 @@                      , hashable             >=1.1   && <1.3                      , time                 >=1.4   && <1.6                      , process              >=1.2   && <1.3+                     , unix-compat          >=0.4   && <0.5+                     , http-date            >=0.0   && <0.1    if impl(ghc < 7.8)     build-depends:     tagged               >=0.7   && <0.8
src/Control/Monad/Apiary/Action/Internal.hs view
@@ -16,6 +16,8 @@  module Control.Monad.Apiary.Action.Internal where +import System.PosixCompat.Files+ import Control.Applicative import Control.Monad import Control.Monad.Trans@@ -25,6 +27,7 @@ import Control.Monad.Trans.Control  import Network.Mime hiding (Extension)+import Network.HTTP.Date import Network.HTTP.Types import Network.Wai import qualified Network.Wai.Parse as P@@ -426,15 +429,26 @@ reset = modifyState (\s -> s { actionResponse = mempty } )  -- | set response body file content, without set Content-Type. since 0.1.0.0.-file' :: Monad m => FilePath -> Maybe FilePart -> ActionT exts m ()+file' :: MonadIO m => FilePath -> Maybe FilePart -> ActionT exts m () file' f p = modifyState (\s -> s { actionResponse = ResponseFile f p } )  -- | set response body file content and detect Content-Type by extension. since 0.1.0.0.-file :: Monad m => FilePath -> Maybe FilePart -> ActionT exts m ()+--+-- file modification check since 0.17.2.+file :: MonadIO m => FilePath -> Maybe FilePart -> ActionT exts m () file f p = do-    mime <- mimeType <$> getConfig-    contentType (mime f)-    file' f p+    mbims <- (>>= parseHTTPDate) . lookup "If-Modified-Since" <$> getHeaders+    e <- liftIO $ fileExist f+    t <- if e+         then liftIO $ Just . epochTimeToHTTPDate . modificationTime <$> getFileStatus f+         else return Nothing+    case mbims of+        Just ims | maybe False (ims >=) t -> reset >> status status304 >> stop+        _ -> do+            mime <- mimeType <$> getConfig+            contentType (mime f)+            maybe (return ()) (addHeader "Last-Modified" . formatHTTPDate) t+            file' f p  -- | append response body from builder. since 0.1.0.0. builder :: Monad m => Builder -> ActionT exts m ()