yesod-json 1.0.0.1 → 1.0.1.0
raw patch · 2 files changed
+13/−8 lines, 2 filesPVP ok
version bump matches the API change (PVP)
API changes (from Hackage documentation)
+ Yesod.Json: acceptsJson :: Yesod master => GHandler sub master Bool
Files
- Yesod/Json.hs +12/−7
- yesod-json.cabal +1/−1
Yesod/Json.hs view
@@ -18,6 +18,7 @@ -- * Convenience functions , jsonOrRedirect+ , acceptsJson ) where import Yesod.Handler (GHandler, waiRequest, lift, invalidArgs, redirect)@@ -109,7 +110,8 @@ -- | jsonOrRedirect simplifies the scenario where a POST handler sends a different -- response based on Accept headers: ----- 1. 200 with JSON data if the client prefers application/json (e.g. AJAX).+-- 1. 200 with JSON data if the client prefers+-- @application\/json@ (e.g. AJAX, see 'acceptsJSON'). -- -- 2. 3xx otherwise, following the PRG pattern. jsonOrRedirect :: (Yesod master, J.ToJSON a)@@ -120,9 +122,12 @@ q <- acceptsJson if q then jsonToRepJson (J.toJSON j) else redirect r- where- acceptsJson = maybe False ((== "application/json") . B8.takeWhile (/= ';'))- . join- . fmap (headMay . parseHttpAccept)- . lookup "Accept" . requestHeaders- <$> waiRequest++-- | Returns @True@ if the client prefers @application\/json@ as+-- indicated by the @Accept@ HTTP header.+acceptsJson :: Yesod master => GHandler sub master Bool+acceptsJson = maybe False ((== "application/json") . B8.takeWhile (/= ';'))+ . join+ . fmap (headMay . parseHttpAccept)+ . lookup "Accept" . requestHeaders+ <$> waiRequest
yesod-json.cabal view
@@ -1,5 +1,5 @@ name: yesod-json-version: 1.0.0.1+version: 1.0.1.0 license: MIT license-file: LICENSE author: Michael Snoyman <michael@snoyman.com>