The wai-routes package

[Tags: library, mit]

Provides easy to use typesafe URLs for Wai Applications. See README for more information. Also see examples/ directory for usage examples.


[Skip to ReadMe]

Properties

Versions0.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
Change logNone available
Dependenciesaeson (>=0.8 && <0.10), base (>=4.7 && <4.9), blaze-builder (==0.4.*), bytestring (==0.10.*), containers (==0.5.*), http-types (==0.8.*), monad-loops (==0.4.*), mtl (>=2.1 && <2.3), path-pieces (==0.2.*), random (==1.1.*), template-haskell (>=2.9 && <2.11), text (==1.2.*), wai (==3.0.*) [details]
LicenseMIT
AuthorAnupam Jain
Maintainerajnsit@gmail.com
StabilityExperimental
CategoryNetwork
Home pagehttps://ajnsit.github.io/wai-routes/
Source repositoryhead: git clone http://github.com/ajnsit/wai-routes
this: git clone http://github.com/ajnsit/wai-routes/tree/v0.7.2(tag v0.7.2)
UploadedThu Jul 30 06:49:47 UTC 2015 by AnupamJain
DistributionsNixOS:0.7.1, Stackage:0.7.1
Downloads2159 total (220 in last 30 days)
Votes
1 []
StatusDocs available [build log]
Last success reported on 2015-07-30 [all 1 reports]

Modules

[Index]

Downloads

Maintainers' corner

For package maintainers and hackage trustees

Readme for wai-routes-0.7.2

Wai-Routes Hackage Hackage-Deps Build Status Coverage Status

This package provides typesafe URLs for Wai applications.

Features:

The aim is to provide a similar level of typesafe URL functionality to Wai applications as is available to Yesod applications.

Planned Features

The following features are planned for later releases -

Performance

When it comes to performance, Wai-routes compares quite favorably with other Haskell web development micro frameworks.

See more details here - philopon/apiary-benchmark

result

Example Usage

The following builds a simple JSON service (using Aeson for JSON conversion)

{-# 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 = ...
-- Delete Single User
postUserDeleteR :: Int -> Handler MyRoute
postUserDeleteR userid = ...

-- Define Application using RouteM Monad
myApp = do
  db <- liftIO $ newIORef mydb
  route (MyRoute db)
  setDefaultAction $ staticApp $ defaultFileServerSettings "static"

-- Run the application
main :: IO ()
main = run 8080 (waiApp myApp)

Changelog