firefly-0.2.0.0: A simple HTTP server framework

Safe HaskellNone
LanguageHaskell2010

Web.Firefly.Handler

Synopsis

Documentation

route :: ToResponse r => Pattern -> Handler r -> App () Source #

Run a handler on a matching route. The handler may return any type which implements ToResponse

If a route matches any actions following it in the App monad will not be run.

Route patterns support pcre regex but do not yet support url parameters.

In the following example if we call helloHarry then the helloHandler will run, but NOT the helloHarryHandler since a matching route ceases further execution. For this reason the order you define your routes in matters.

app :: App ()
app = do
  route "/" indexHandler
  route "/hello.*" helloHandler
  route "/helloHarry" helloHarryHandler