Safe Haskell | Safe-Infered |
---|
Frank is a Sinatra-inspired DSL (see http://www.sinatrarb.com) for creating
routes. It is composable with all Routeable
types, but is designed to be used
with Controller
s. Each verb (get
, post
, put
, etc') takes a
URL pattern of the form "/dir/:paramname/dir" (see routePattern
for
details) and a Routeable
:
main :: IO () main = runSettings defaultSettings $ mkRouter $ do get "/" $ do req <- request return $ okHtml $ fromString $ "Welcome Home " ++ (show $ serverName req) get "/user/:id" $ do userId <- queryParam "id" >>= fromMaybe "" return $ ok "text/json" $ fromString $ "{\"myid\": " ++ (show userId) ++ "}" put "/user/:id" $ do ...
- get :: Routeable r => ByteString -> r -> Route ()
- post :: Routeable r => ByteString -> r -> Route ()
- put :: Routeable r => ByteString -> r -> Route ()
- delete :: Routeable r => ByteString -> r -> Route ()
- options :: Routeable r => ByteString -> r -> Route ()
Documentation
get :: Routeable r => ByteString -> r -> Route ()Source
Matches the GET method on the given URL pattern
post :: Routeable r => ByteString -> r -> Route ()Source
Matches the POST method on the given URL pattern
put :: Routeable r => ByteString -> r -> Route ()Source
Matches the PUT method on the given URL pattern