Safe Haskell | Trustworthy |
---|---|
Language | Haskell2010 |
Frank is a Sinatra-inspired DSL (see http://www.sinatrarb.com) for creating
routes. It is composable with all ToApplication
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 ToApplication
:
main :: IO () main = run 3000 $ controllerApp () $ do get "/" $ do req <- request respond $ okHtml $ fromString $ "Welcome Home " ++ (show $ serverName req) get "/user/:id" $ do userId <- queryParam "id" >>= fromMaybe "" respond $ ok "text/json" $ fromString $ "{\"myid\": " ++ (show userId) ++ "}" put "/user/:id" $ do ...
Synopsis
- get :: Monad m => Text -> ControllerT s m a -> ControllerT s m ()
- post :: Monad m => Text -> ControllerT s m a -> ControllerT s m ()
- put :: Monad m => Text -> ControllerT s m a -> ControllerT s m ()
- patch :: Monad m => Text -> ControllerT s m a -> ControllerT s m ()
- delete :: Monad m => Text -> ControllerT s m a -> ControllerT s m ()
- options :: Monad m => Text -> ControllerT s m a -> ControllerT s m ()
Documentation
get :: Monad m => Text -> ControllerT s m a -> ControllerT s m () Source #
Matches the GET method on the given URL pattern
post :: Monad m => Text -> ControllerT s m a -> ControllerT s m () Source #
Matches the POST method on the given URL pattern
put :: Monad m => Text -> ControllerT s m a -> ControllerT s m () Source #
Matches the PUT method on the given URL pattern
patch :: Monad m => Text -> ControllerT s m a -> ControllerT s m () Source #
Matches the PATCH method on the given URL pattern
delete :: Monad m => Text -> ControllerT s m a -> ControllerT s m () Source #
Matches the DELETE method on the given URL pattern
options :: Monad m => Text -> ControllerT s m a -> ControllerT s m () Source #
Matches the OPTIONS method on the given URL pattern