view Routes.hs @ 11:5671c12701d0 default tip

fix makefile
author Daichi TOMA <toma@cr.ie.u-ryukyu.ac.jp>
date Tue, 11 Feb 2014 19:15:16 +0900
parents 782efee9766c
children
line wrap: on
line source

{-# LANGUAGE OverloadedStrings #-}

module Routes
( routes
) where

import Jungle
import Types
import RouteSetting
import Network.Wai (Response, responseLBS)
import Network.Wai.Parse (Param)
import Network.HTTP.Types (status404)
import Network.HTTP.Types.URI (Query)
import Data.Text (Text)


routes :: [Text] -> (Jungle -> Query -> [Param] -> IO Response)
routes path = findRoute path routeSetting

findRoute path [] = notFound
findRoute path ((p,f):xs)
    | path == p = f
    | otherwise = findRoute path xs

notFound :: Jungle -> Query -> [Param] -> IO Response
notFound _ _ _ = 
    return $ responseLBS status404 [("Content-type", "text/html")] $ "404 - File Not Found"