wai-routes-0.5.1: wai-routes.cabal
name : wai-routes
version : 0.5.1
cabal-version : >=1.10
build-type : Simple
license : MIT
license-file : LICENSE
maintainer : ajnsit@gmail.com
stability : Experimental
homepage : https://github.com/ajnsit/wai-routes
synopsis : Typesafe URLs for Wai applications.
description : 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
@
category : Network
author : Anupam Jain
data-dir : ""
extra-source-files : README.md examples/Example.hs
source-repository head
type : git
location : http://github.com/ajnsit/wai-routes
source-repository this
type : git
location : http://github.com/ajnsit/wai-routes/tree/v0.5.1
tag : v0.5.1
library
build-depends: base >= 4.6.0.1 && < 4.7
, wai >= 2.0.0 && < 2.2
, text >= 0.11.3.1 && < 1.2
, bytestring >= 0.10.0.2 && < 0.11
, http-types >= 0.8.3 && < 0.9
, blaze-builder >= 0.3.3.2 && < 0.4
, template-haskell >= 2.8.0.0 && < 2.9
, yesod-routes >= 1.2.0.6 && < 1.3
, mtl >= 2.1.2 && < 2.2
, aeson >= 0.7.0.1 && < 0.8
exposed-modules: Network.Wai.Middleware.Routes
Network.Wai.Middleware.Routes.Routes
Network.Wai.Middleware.Routes.Monad
Network.Wai.Middleware.Routes.Handler
Network.Wai.Middleware.Routes.ContentTypes
exposed : True
buildable : True
hs-source-dirs : src
default-language : Haskell2010