module Hack.Contrib.Middleware.RawRouter (route) where import Hack import Hack.Contrib.Utils import Hack.Contrib.Request hiding (path) 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