hack-2009.4.25: src/Hack/Contrib/RawRouter.hs
module Hack.Contrib.RawRouter where
import Hack
import Hack.Utils
import Hack.Request
import MPSUTF8
import Prelude hiding ((.), (^), (>))
import List (find)
import Data.Maybe
type RoutePath = (String, Application)
route :: [RoutePath] -> MiddleWare
route h app = \env ->
let path = env.fullpath
in
case h.find (fst > flip match path > isJust) of
Nothing -> app env
Just (_, found_app) -> found_app env