module Rakka.Resource.Page ( fallbackPage ) where import Data.Char import Network.HTTP.Lucu import Network.HTTP.Lucu.Utils import Rakka.Environment import Rakka.Page import Rakka.Resource.Page.Get fallbackPage :: Environment -> [String] -> IO (Maybe ResourceDef) fallbackPage env path | null path = return Nothing | null $ head path = return Nothing | not $ isUpper $ head $ head path = return Nothing -- /Foo/bar のような形式でない。 | otherwise = return $ Just $ ResourceDef { resUsesNativeThread = False , resIsGreedy = True , resGet = Just $ handleGet env (toPageName path) , resHead = Nothing , resPost = Nothing , resPut = Just $ handlePut env (toPageName path) , resDelete = Just $ handleDelete env (toPageName path) } toPageName :: [String] -> PageName toPageName = decodePageName . joinWith "/" handlePut :: Environment -> PageName -> Resource () handlePut = fail "FIXME: not implemented" handleDelete :: Environment -> PageName -> Resource () handleDelete = fail "FIXME: not implemented"