@hackage apiary0.5.0.0

Simple web framework inspired by scotty.

Simple web framework inspired by scotty.

{-# LANGUAGE QuasiQuotes #-}
{-# LANGUAGE OverloadedStrings #-}

import Web.Apiary
import Network.Wai.Handler.Warp
import qualified Data.ByteString.Lazy.Char8 as L

main :: IO ()
main = run 3000 . runApiary def $ do
  [capture|/:Int|] . ("name" =: pLazyByteString) . stdMethod GET . action $ \age name -> do
      guard (age >= 18)
      contentType "text/html"
      lbs . L.concat $ ["<h1>Hello, ", name, "!</h1>\n"]
$ curl localhost:3000
404 Page Notfound.
$ curl 'localhost:3000/20?name=arice'
<h1>Hello, arice!</h1>
$ curl 'localhost:3000/15?name=bob'
404 Page Notfound.
$ curl -XPOST 'localhost:3000/20?name=arice'
404 Page Notfound.
  • Nestable route handling(ApiaryT Monad; capture, stdMethod and more.).

  • type safe route filter.

full example & tutorial: https://github.com/philopon/apiary/blob/master/examples/main.lhs

  • Installation

  • Dependencies (0)

  • Dependents (0)