Created
October 20, 2015 11:05
-
-
Save parambirs/481ee0359a7951318be9 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
main = scotty 3000 $ do | |
-- get article (json) | |
get "/article" $ do | |
json $ Article 13 "caption" "content" -- Call Article constructor and encode the result as JSON | |
-- post article (json) | |
post "/article" $ do | |
article <- jsonData :: ActionM Article -- Decode body of the POST request as an Article object | |
json article -- Send the encoded object back as JSON |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment