I'm trying to use Scotty in Haskell, and following a tutorial, I could route a url like so:
get "/hello/:name" $ do
name <- param "name"
text ("Hello " <> name <> "!!")
However, what is the syntax to capture multiple route parameters? Neither of the following worked:
post "/newuser/:id/:name" $ do
id <- param "id"
name <- param "name"
json $ User {userId = id, userName = name}
get "/users/{id}" $ do
id <- param "id"
json $ filter (matchesId id) allUsers
HTTP method is part of route matching in Scotty.
To match your POST
route, you have to test it with a POST
request, or Scotty will answer with a 404 http error.