wai-middleware-route-0.1: Wai dispatch middleware

Network.Wai.Middleware.Route

Description

Route middleware for wai.

It's Heavy inspired by vhost middleware from wai-extra but gives some sugar to life.

Synopsis

Documentation

type Rule = Request -> BoolSource

Routing rule

type Route = (Rule, Application)Source

Route for dispatch

dispatchSource

Arguments

:: [Route]

List of routes

-> Application

Default Application

-> Application

Returns founded Application. If not found - returns default.

Dispatch. Seek for first route where the Rule gives a positive result. Uses find instead filter in vhost

 dispatch [
     ((=="/") . rawPathInfo, auth . cache . Issues.get)
   , ((=="/issues") . rawPathInfo, cache . About.handle)
   ] defaultApp

(&~~)Source

Arguments

:: Method

HTTP Method

-> ByteString

Request path pattern.

-> Rule

Routing rule

Syntax shugar for most frequently case: HTTP Method and Request path regex pattern.

 ("GET" &~~ "^/issues", app)