From b2c715f2231296ce50828eeca122449e4d17fe3d Mon Sep 17 00:00:00 2001 From: Bryan Richter Date: Sat, 14 Jan 2012 09:13:47 -0800 Subject: [PATCH] Small refactor to jsonOrRedirect --- yesod-json/Yesod/Json.hs | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/yesod-json/Yesod/Json.hs b/yesod-json/Yesod/Json.hs index 509367a1..78d394a9 100644 --- a/yesod-json/Yesod/Json.hs +++ b/yesod-json/Yesod/Json.hs @@ -119,7 +119,8 @@ jsonOrRedirect r j = do if q then jsonToRepJson (J.toJSON j) else redirect r where - acceptsJson = maybe False ("application/json" `B.isPrefixOf`) <$> firstAccept - firstAccept = return . join + acceptsJson = maybe False ("application/json" `B.isPrefixOf`) + . join . fmap (headMay . parseHttpAccept) - =<< lookup "Accept" . requestHeaders <$> waiRequest + . lookup "Accept" . requestHeaders + <$> waiRequest