-- | matching a list of regexp agains a path_info, if matched, consponding app -- is used, otherwise, pass the env down to lower middleware module Hack.Contrib.Middleware.RegexpRouter (regexp_router) where import Hack import Hack.Contrib.Utils import MPSUTF8 import Prelude hiding ((.), (^), (>)) import List (find) import Data.Maybe type RoutePath = (String, Application) regexp_router :: [RoutePath] -> Middleware regexp_router h app = \env -> let path = env.path_info in case h.find (fst > flip match path > isJust) of Nothing -> app env Just (_, found_app) -> found_app env