wai-router-1.0.0.0: Provides basic routing on URL paths for WAI.

Safe HaskellSafe-Infered

Network.Wai.Middleware.Router

Synopsis

Documentation

type Route = [Text] -> Maybe ApplicationSource

Alias for a function which maps path pieces to applications.

router :: [Route] -> Application -> ApplicationSource

Router for mapping paths to applications.

For example:

 router [ dir "/foo" fooApp
        , dir "/api" apiApp 
        ] defaultApp

dir :: Text -> Application -> RouteSource

A possible web application if the path matches, nothing otherwise.

For example:

 let f = dir "/foo/api" myApp
 f ["foo","api"]
 True
 f ["foo","spi"]
 False