@hackage apiary0.12.3
Simple and type safe web framework that can be automatically generate API documentation.
Categories
License
MIT
Maintainer
HirotomoMoriwaki<philopon.dependence@gmail.com>
Links
Versions
Installation
Dependencies (18)
- base >=4.6 && <4.8
- blaze-builder >=0.3 && <0.4
- blaze-html >=0.7 && <0.8
- bytestring >=0.10 && <0.11
- conduit >=1.1 && <1.2
- data-default-class >=0.0 && <0.1 Show all…
Dependents (15)
@hackage/apiary-memcached, @hackage/apiary-persistent, @hackage/apiary-mongoDB, @hackage/apiary-cookie, @hackage/apiary-session, @hackage/acme-everything, Show all…
Package Flags
wai3
(on by default)
use wai-3.0
Simple and type safe web framework that can be automatically generate API documentation.
{-# 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(Apiary Monad; capture, stdMethod and more.).
type safe route filter.
auto generate API documentation(example: https://github.com/philopon/apiary/blob/master/examples/api.hs, https://rawgit.com/philopon/apiary/master/examples/api.html).
more examples: https://github.com/philopon/apiary/blob/master/examples/