Created
July 12, 2011 15:39
-
-
Save ocharles/1078227 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
bookResource :: Controller () | |
bookResource = do | |
gid <- ((fromString . unpack . fromJust) <$> getParam "gid") >>= (\gid' -> gid' `onNothing` "Invalid BBID") | |
maybeBook <- model $ getBook gid | |
case maybeBook of | |
Nothing -> generic404 "The request book could not be found" | |
Just book -> do | |
book <- model $ loadAuthorCredit book | |
book <- model $ set lBookAuthorCredit book <$> (loadForAuthorCredits $ bookAuthorCredit book) | |
editions <- model $ findBookEditions book | |
output $ showBook book editions | |
where onNothing (Just a) _ = return a | |
onNothing Nothing message = throwError message | |
set field on = \val -> setL field val on |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment