https://github.com/alexmingoia/twain
Tiny web application framework for WAI.
https://github.com/alexmingoia/twain
framework haskell web web-framework webapp-framework
Last synced: 12 months ago
JSON representation
Tiny web application framework for WAI.
- Host: GitHub
- URL: https://github.com/alexmingoia/twain
- Owner: alexmingoia
- License: bsd-3-clause
- Created: 2021-05-11T08:04:01.000Z (almost 5 years ago)
- Default Branch: main
- Last Pushed: 2024-11-05T23:21:18.000Z (over 1 year ago)
- Last Synced: 2025-03-29T05:05:18.259Z (12 months ago)
- Topics: framework, haskell, web, web-framework, webapp-framework
- Language: Haskell
- Homepage:
- Size: 40 KB
- Stars: 70
- Watchers: 6
- Forks: 3
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- Changelog: changelog.md
- License: LICENSE
Awesome Lists containing this project
README
# Twain
[](http://hackage.haskell.org/package/twain)

Twain is a tiny web application framework for
[WAI](http://hackage.haskell.org/package/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.
```haskell
{-# 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..."
```