wai-routes: Typesafe URLs for Wai applications.
Provides easy to use typesafe URLs for Wai Applications.
Sample usage follows (See examples/Example.hs in the source bundle for the full code) -
{-# LANGUAGE OverloadedStrings, TypeFamilies #-}
import Network.Wai
import Network.Wai.Middleware.Routes
import Data.IORef
-- The Site Argument
data MyRoute = MyRoute (IORef DB)
-- Generate Routes
mkRoute MyRoute [parseRoutes|
/ UsersR GET
/user/#Int UserR:
/ UserRootR GET
/delete UserDeleteR POST
|]
-- Define Handlers
-- All Users Page
getUsersR :: Handler MyRoute
getUsersR (MyRoute dbref) request = ...
-- Single User Page
getUserRootR :: Int -> Handler MyRoute
getUserRootR userid (MyRoute dbref) request = ...
-- Delete Single User
postUserDeleteR :: Int -> Handler MyRoute
postUserDeleteR userid (MyRoute dbref) request = ...
-- Define Application using RouteM Monad
myApp = do
db <- liftIO $ newIORef mydb
route (MyRoute db)
setDefaultAction $ staticApp $ defaultFileServerSettings "static"
-- Run the application
main :: IO ()
main = toWaiApp myApp >>= run 8080
[Skip to Readme]
Modules
- Network
- Wai
- Middleware
- Network.Wai.Middleware.Routes
- Network.Wai.Middleware.Routes.Class
- Network.Wai.Middleware.Routes.ContentTypes
- Network.Wai.Middleware.Routes.Handler
- Network.Wai.Middleware.Routes.Monad
- Network.Wai.Middleware.Routes.Overlap
- Network.Wai.Middleware.Routes.Parse
- Network.Wai.Middleware.Routes.Routes
- TH
- Network.Wai.Middleware.Routes.TH.Dispatch
- Network.Wai.Middleware.Routes.TH.ParseRoute
- Network.Wai.Middleware.Routes.TH.RenderRoute
- Network.Wai.Middleware.Routes.TH.RouteAttrs
- Network.Wai.Middleware.Routes.TH.Types
- Network.Wai.Middleware.Routes
- Middleware
- Wai
Downloads
- wai-routes-0.6.0.tar.gz [browse] (Cabal source package)
- Package description (as included in the package)
Maintainer's Corner
For package maintainers and hackage trustees
Candidates
- No Candidates
Versions [RSS] | 0.1, 0.2, 0.2.1, 0.2.2, 0.2.3, 0.2.4, 0.3.0, 0.3.1, 0.3.2, 0.3.3, 0.3.4, 0.4.0, 0.4.1, 0.5.0, 0.5.1, 0.6.0, 0.6.1, 0.6.2, 0.7.0, 0.7.1, 0.7.2, 0.7.3, 0.8.0, 0.8.1, 0.9.0, 0.9.1, 0.9.2, 0.9.3, 0.9.4, 0.9.5, 0.9.6, 0.9.7, 0.9.8, 0.9.9, 0.9.10, 0.10.0, 0.10.1, 0.10.2, 0.10.3, 0.10.4 |
---|---|
Dependencies | aeson (>=0.8 && <0.9), base (>=4.7 && <4.9), blaze-builder (>=0.4 && <0.5), bytestring (>=0.10 && <0.11), containers (>=0.5 && <0.6), http-types (>=0.8 && <0.9), mtl (>=2.1 && <2.3), path-pieces (>=0.2 && <0.3), random (>=1.1 && <1.2), template-haskell (>=2.9 && <2.11), text (>=1.2 && <1.3), wai (>=3.0 && <3.1) [details] |
License | MIT |
Author | Anupam Jain |
Maintainer | ajnsit@gmail.com |
Category | Network |
Home page | https://github.com/ajnsit/wai-routes |
Source repo | head: git clone http://github.com/ajnsit/wai-routes this: git clone http://github.com/ajnsit/wai-routes/tree/v0.6(tag v0.6) |
Uploaded | by AnupamJain at 2015-05-28T06:07:32Z |
Distributions | |
Reverse Dependencies | 2 direct, 0 indirect [details] |
Downloads | 26786 total (123 in the last 30 days) |
Rating | 2.0 (votes: 1) [estimated by Bayesian average] |
Your Rating | |
Status | Docs not available [build log] All reported builds failed as of 2016-12-09 [all 5 reports] |