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)
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