Wheb: The Batteries-Included Haskell WAI Framework
This is a package candidate release! Here you can preview how this package release will appear once published to the main package index (which can be accomplished via the 'maintain' link below). Please note that once a package has been published to the main package index it cannot be undone! Please consult the package uploading documentation for more information.
Warnings:
- Exposed modules use unallocated top-level names: Web
Wheb aims at providing a simple simple and straightforward web server.
import Web.Wheb import Data.Text.Lazy (pack) main :: IO () main = do opts <- generateOptions $ addGET (pack ".") rootPat $ (text (pack "Hi!")) runWhebServer (opts :: MinOpts)
Wheb makes it easy to share a global context and handle requests statefully
import Control.Concurrent.STM
import Control.Monad.IO.Class
import Data.Monoid
import Data.Text.Lazy (Text, pack)
import Web.Wheb
data MyApp = MyApp Text (TVar Int)
data MyHandlerData = MyHandlerData Int
instance Default MyHandlerData where
def = MyHandlerData 0
counterMw :: MonadIO m => WhebMiddleware MyApp MyHandlerData m
counterMw = do
(MyApp _ ctr) <- getApp
number <- liftIO $ readTVarIO ctr
liftIO $ atomically $ writeTVar ctr (succ number)
putReqState (MyHandlerData number)
return Nothing
homePage :: WhebHandler MyApp MyHandlerData
homePage = do
(MyApp appName _) <- getApp
(MyHandlerData num) <- getReqState
html $ ("<h1>Welcome to" <> appName <>
"</h1><h2>You are visitor #" <> (pack $ show num) <> "</h2>")
main :: IO ()
main = do
opts <- generateOptions $ do
startingCounter <- liftIO $ newTVarIO 0
addWhebMiddleware counterMw
addGET (pack ".") rootPat $ homePage
return $ MyApp "AwesomeApp" startingCounter
runWhebServer optsWheb allows you to write robust high concurrency web applications simply and effectively.
The core datatype will allow you to build anything from a read-only server to a fully interactive web application with hundreds of routes without needing to define MonadTransformers.
Minimal boilerplate to start your application.
Plugin system
Properties
| Versions | 0.0.1.0, 0.0.1.1, 0.0.1.1, 0.1.0.0, 0.2.0.0, 0.3.0.0, 0.3.1.0 |
|---|---|
| Change log | None available |
| Dependencies | base (>=4.6 && <4.7), blaze-builder (>=0.3 && <0.4), bytestring (>=0.10 && <0.11), case-insensitive (>=1.0 && <1.1), conduit (>=1.0 && <1.1), containers (>=0.5 && <0.6), cookie (>=0.4 && <0.5), data-default (>=0.5 && <0.6), http-types (>=0.8 && <0.9), mtl (>=2.1 && <2.2), pwstore-fast (>=2.4 && <2.5), stm (>=2.4 && <2.5), text (>=0.11 && <0.12), time (>=1.4 && <1.5), transformers (>=0.3 && <0.4), uuid (>=1.3 && <1.4), wai (>=2.0 && <2.1), wai-extra (>=2.0 && <2.1), warp (>=2.0 && <2.1) [details] |
| License | BSD-3-Clause |
| Author | Kyle Hanson |
| Maintainer | hanooter@gmail.com |
| Category | Web |
| Home page | https://github.com/hansonkd/Wheb-Framework |
| Source repo | head: git clone git://github.com/hansonkd/Wheb-Framework.git |
| Uploaded | by hansonkd at 2014-02-06T20:57:34Z |
Modules
- Web
- Web.Wheb
- Web.Wheb.Cookie
- Web.Wheb.InitM
- Web.Wheb.Internal
- Plugins
- Web.Wheb.Plugins.Auth
- Debug
- Web.Wheb.Plugins.Debug.MemoryBackend
- Web.Wheb.Plugins.Session
- Web.Wheb.Routes
- Web.Wheb.Types
- Web.Wheb.Utils
- Web.Wheb.WhebT
- Web.Wheb
Downloads
- Wheb-0.0.1.1.tar.gz [browse] (Cabal source package)
- Package description (as included in the package)
Maintainer's Corner
Package maintainers
For package maintainers and hackage trustees