Skip to content

Instantly share code, notes, and snippets.

@parambirs
Created October 20, 2015 11:05
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save parambirs/481ee0359a7951318be9 to your computer and use it in GitHub Desktop.
Save parambirs/481ee0359a7951318be9 to your computer and use it in GitHub Desktop.
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