@hackage apiary2.1.2
Simple and type safe web framework that generate web API documentation.
Categories
License
MIT
Maintainer
HirotomoMoriwaki<philopon.dependence@gmail.com>, 韩冬<drkoster@qq.com>
Links
Versions
Installation
Dependencies (32)
- aeson >=0.8 && <1.3
- base >=4.7 && <5.0
- blaze-builder >=0.3 && <0.5
- blaze-html >=0.7 && <0.9
- blaze-markup >=0.6 && <0.8
- bytestring >=0.10 && <0.11 Show all…
Dependents (15)
@hackage/apiary-memcached, @hackage/apiary-persistent, @hackage/apiary-mongoDB, @hackage/apiary-cookie, @hackage/apiary-session, @hackage/acme-everything, Show all…
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 = runApiary (run 3000) def $ do
[capture|/age::Int|] . ([key|name|] =: pLazyByteString) . method GET . action $ do
(age, name) <- [params|age,name|]
guard (age >= 18)
contentType "text/html"
mapM_ appendLazyBytes ["<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.
High performance(benchmark: https://github.com/philopon/apiary-benchmark).
Nestable route handling(Apiary Monad; capture, method and more.).
Type safe route filter.
Auto generate API documentation(example: http://find-hackage.herokuapp.com/api/documentation).
more examples: https://github.com/philopon/apiary/blob/v1.4.0/examples/
live demo: http://find-hackage.herokuapp.com/ (source code: https://github.com/philopon/find-hackage)