Small refactor to jsonOrRedirect

This commit is contained in:
Bryan Richter 2012-01-14 09:13:47 -08:00
parent c6a08f0c4a
commit b2c715f223

View File

@ -119,7 +119,8 @@ jsonOrRedirect r j = do
if q then jsonToRepJson (J.toJSON j) if q then jsonToRepJson (J.toJSON j)
else redirect r else redirect r
where where
acceptsJson = maybe False ("application/json" `B.isPrefixOf`) <$> firstAccept acceptsJson = maybe False ("application/json" `B.isPrefixOf`)
firstAccept = return . join . join
. fmap (headMay . parseHttpAccept) . fmap (headMay . parseHttpAccept)
=<< lookup "Accept" . requestHeaders <$> waiRequest . lookup "Accept" . requestHeaders
<$> waiRequest