module Hack.Contrib.RawRouter where

import Hack
import Hack.Utils
import List (find)
import Prelude hiding ((.), (^), (>))
import MPS
import Data.Maybe (isJust)

type RoutePath = (String, Application)

route :: [RoutePath] -> MiddleWare
route 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