Skip to content

Instantly share code, notes, and snippets.

@parambirs

parambirs/Main.hs

Created Oct 20, 2015
Embed
What would you like to do?
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