view Routes.hs @ 4:124384cddb7e

fix port number 8080 from 3000
author Daichi TOMA <toma@cr.ie.u-ryukyu.ac.jp>
date Sat, 13 Jul 2013 01:31:11 +0900
parents 622f5598f951
children 782efee9766c
line wrap: on
line source

{-# LANGUAGE OverloadedStrings #-}

module Routes (routes) where

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

routes :: [Text] -> (TJungle -> 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 _ _ _ = do
    return $ responseLBS status404 [("Content-type", "text/html")] $ "404 - File Not Found"