@hackage twain2.2.0.1
Tiny web application framework for WAI.
Categories
License
BSD-3-Clause
Maintainer
alex@alexmingoia.com
Links
Versions
Installation
Dependencies (15)
- aeson >=2 && <3
- base >=4.7 && <5
- bytestring >=0.10 && <0.12
- case-insensitive >=1.2 && <1.3
- cookie >=0.4 && <0.6
- either >=5.0 && <5.1 Show all…
Dependents (0)
Twain
Twain is a tiny web application framework for WAI.
ResponderMfor composing responses with do notation.- Routing with path captures that decompose
ResponderMinto middleware. - Parameter parsing from cookies, path, query, and body.
- Helpers for redirects, headers, status codes, and errors.
{-# language OverloadedStrings #-}
import Network.Wai.Handler.Warp (run)
import Web.Twain
main :: IO ()
main = do
run 8080 $
foldr ($) (notFound missing) routes
routes :: [Middleware]
routes =
[ get "/" index
, post "/echo/:name" echoName
]
index :: ResponderM a
index = send $ html "Hello World!"
echoName :: ResponderM a
echoName = do
name <- param "name"
send $ html $ "Hello, " <> name
missing :: ResponderM a
missing = send $ html "Not found..."