Skip to content

Instantly share code, notes, and snippets.



Created Oct 20, 2015
What would you like to do?
-- set a header:
post "/set-headers" $ do
status status302 -- Respond with HTTP 302 status code
setHeader "Location" ""
-- named parameters:
get "/askfor/:word" $ do
w <- param "word"
html $ mconcat ["<h1>You asked for ", w, ", you got it!</h1>" ]
-- unnamed parameters from a query string or a form:
post "/submit" $ do -- e.g.
name <- param "name"
text name
-- match a route regardless of the method
matchAny "/all" $ do
text "matches all methods"
-- handler for when there is no matched route
-- (this should be the last handler because it matches all routes)
notFound $ do
text "there is no such route."
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment