Support ?style=plain on haddocks

This commit is contained in:
Michael Snoyman 2017-12-08 10:17:19 +02:00
parent 950cb7ef6d
commit eac18f4b1b
No known key found for this signature in database
GPG Key ID: A048E8C057E86876

View File

@ -50,12 +50,17 @@ getHaddockR slug rest
addExtra t = [t]
req <- parseRequest $ unpack $ makeURL slug rest
(_, res) <- acquireResponse req >>= allocateAcquire
doc <- responseBody res
$$ eventConduit
=$ concatMapC addExtra
=$ mapC (Nothing, )
=$ fromEvents
sendResponse $ toHtml doc
mstyle <- lookupGetParam "style"
case mstyle of
Just "plain" -> respondSource "text/html; charset=utf-8"
$ responseBody res .| mapC (Chunk . toBuilder)
_ -> do
doc <- responseBody res
$$ eventConduit
=$ concatMapC addExtra
=$ mapC (Nothing, )
=$ fromEvents
sendResponse $ toHtml doc
| otherwise = redirect $ makeURL slug rest
redirectWithVersion