name: Wheb version: 0.2.0.0 synopsis: The frictionless WAI Framework license: BSD3 license-file: LICENSE author: Kyle Hanson homepage: https://github.com/hansonkd/Wheb-Framework maintainer: me@khanson.io category: Web build-type: Simple cabal-version: >=1.10 description: Wheb's a framework for building robust, high-concurrency web applications simply and effectively. . * The core datatype will let you build anything from a read-only server to a fully interactive web application with basic Haskell. . * Minimal boilerplate to start your application. . * Typesafe web-routes or named routes and URL generation. . * Easy to use for REST APIs . * WebSockets . * Fully database and template agnostic . * Easy handler debugging. . * Middleware . * Fast. It deploys on warp. . /Plugins:/ . Wheb makes it easy to write plugins. Plugins can add routes, middlware, settings and even handle resource cleanup on server shutdown. Named routes allow plugins to dynamically generate their routes at runtime based on settings. . Examples of plugins: . * Sessions . * Auth . * . * . /Wheb in action:/ . > import Web.Wheb > import Data.Text.Lazy (pack) > > main :: IO () > main = do > opts <- genMinOpts $ do > addGET "home" rootPat $ (text (pack "Hi!")) > addGET "about" ("about" "something") $ html (pack "

About!

") > runWhebServer opts . /Bigger example (Stateful.hs):/ . Wheb makes it easy to share a global context and handle requests statefully. The Wheb monad is both a Reader and a State Monad allowing you to seperate thread-safe resources. . Below is an example of site that naively counts the non-unique hits across all pages. MyApp is our Reader's type and MyHandlerData is our State's type. MyApp is shared across requests while MyHandlerData is thread specific with a starting state given in options. We have a middleware that intercepts the request, safely increments the shared resource TVar and sets our MyHandlerData to the correct count before it reaches our handler. We use a TVar in the Global context because any state changes to the handler state will not affect other requests. . > 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 > > counterMw :: MonadIO m => WhebMiddleware MyApp MyHandlerData m > counterMw = do > (MyApp _ ctr) <- getApp > number <- liftIO $ atomically $ do > num <- readTVar ctr > writeTVar ctr (succ num) > return num > putHandlerState (MyHandlerData number) > return Nothing > > homePage :: WhebHandler MyApp MyHandlerData > homePage = do > (MyApp appName _) <- getApp > (MyHandlerData num) <- getHandlerState > html $ ("

Welcome to" <> appName <> > "

You are visitor #" <> (spack num) <> "

") > > main :: IO () > main = do > opts <- generateOptions $ do > startingCounter <- liftIO $ newTVarIO 0 > addWhebMiddleware counterMw > addGET (pack ".") rootPat $ homePage > return $ (MyApp "AwesomeApp" startingCounter, MyHandlerData 0) > runWhebServer opts source-repository head type: git location: git://github.com/hansonkd/Wheb-Framework.git library default-language: Haskell2010 exposed-modules: Web.Wheb, Web.Wheb.Cookie, Web.Wheb.InitM, Web.Wheb.Internal, Web.Wheb.Routes, Web.Wheb.Types, Web.Wheb.Utils, Web.Wheb.WhebT, Web.Wheb.Plugins.Auth, Web.Wheb.Plugins.Session, Web.Wheb.Plugins.Debug.MemoryBackend build-depends: base >= 4.7 && < 4.8, text >= 1.0 && < 1.2, transformers >= 0.4 && < 0.5, time >=1.4 && < 1.5, bytestring >= 0.10 && < 0.11, blaze-builder >=0.3 && < 0.4, cookie >=0.4 && < 0.5, mtl >=2.1 && < 2.3, containers >=0.5 && <0.6, wai >= 3.0 && < 3.1, warp >= 3.0 && < 3.1, wai-extra >= 3.0 && < 3.1, http-types >=0.8 && <0.9, case-insensitive >=1.2 && < 1.3, pwstore-fast >=2.4 && < 2.5, uuid >=1.3 && < 1.4, stm >=2.4 && < 2.5, unix >= 2.7 && < 2.8, web-routes >=0.27 && <0.28, websockets >= 0.8 && <0.9, wai-websockets >= 3.0 && < 3.1 hs-source-dirs: src GHC-options: -Wall -fno-warn-orphans test-suite Main type: exitcode-stdio-1.0 build-depends: Wheb ==0.2.*, base ==4.7.*, HUnit >= 1.2 && < 2, QuickCheck >= 2.4, test-framework >= 0.4.1, test-framework-quickcheck2, test-framework-hunit, text >= 1.0 && < 1.2 ghc-options: -Wall -rtsopts hs-source-dirs: tests default-language: Haskell2010 hs-source-dirs: tests main-is: Main.hs