Created
October 20, 2015 11:04
-
-
Save parambirs/efe8ddc0f7d57ca10de1 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
-- set a header: | |
post "/set-headers" $ do | |
status status302 -- Respond with HTTP 302 status code | |
setHeader "Location" "http://www.google.com.au" | |
-- 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. http://server.com/submit?name=somename | |
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