The latest version of wai-routes is 0.10.4-0.

wai-routes

Version 0.3.2 revision 0 uploaded by AnupamJain.

Package meta

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
Author
Anupam Jain
Bug reports
n/a
Category
Network
Copyright
n/a
Homepage
https://github.com/ajnsit/wai-routes
Maintainer
ajnsit@gmail.com
Package URL
n/a
Stability
Experimental

Components