@hackage twain2.0.0.0

Tiny web application framework for WAI.

Twain

Hackage BSD3 License

Twain is a tiny web application framework for WAI.

  • ResponderM for composing responses with do notation.
  • Routing with path captures that decompose ResponderM into middleware.
  • Parameter parsing from cookies, path, query, and body.
  • Helpers for redirects, headers, status codes, and errors.
import Network.Wai.Handler.Warp (run)
import Web.Twain

main :: IO ()
main = do
  run 8080
    $ get "/" index
    $ post "/echo/:name" echoName
    $ notFound missing

index :: ResponderM a
index = send $ html "Hello World!"

echo :: ResponderM a
echo = do
  name <- param "name"
  send $ html $ "Hello, " <> name

missing :: ResponderM a
missing = send $ html "Not found..."