Works with subsites with arguments
This commit is contained in:
parent
ee3fc92111
commit
b3ae5e6149
@ -93,7 +93,7 @@ type Method = String
|
||||
-- to deal with it directly, as mkYesodSub creates instances appropriately.
|
||||
class Eq (Route s) => YesodSubSite s y where
|
||||
getSubSite :: Site (Route s) (Method -> Maybe (GHandler s y ChooseRep))
|
||||
dispatchSubsite :: y -> Maybe CS.Key -> [String] -> (y -> s) -> W.Application
|
||||
dispatchSubsite :: y -> Maybe CS.Key -> [String] -> s -> W.Application
|
||||
dispatchSubsite _ _ _ _ _ = return $ W.responseLBS W.status200 [("Content-Type", "text/plain")] $ L8.pack "FIXME"
|
||||
|
||||
-- | Define settings for a Yesod applications. The only required setting is
|
||||
|
||||
@ -188,7 +188,7 @@ mkYesodGeneral name args clazzes isSub res = do
|
||||
master <- newName "master"
|
||||
mkey <- newName "mkey"
|
||||
just <- [|Just|]
|
||||
(pat', tma', rest) <- mkPat' pieces $ just `AppE` (VarE $ mkName toSub)
|
||||
(pat', tma', rest) <- mkPat' pieces $ just `AppE` (VarE (mkName toSub) `AppE` VarE master)
|
||||
ds <- [|dispatchSubsite|]
|
||||
let body' = ds `AppE` VarE master `AppE` VarE mkey `AppE` rest
|
||||
fmap' <- [|(<$>)|]
|
||||
@ -260,12 +260,12 @@ mkToMasterArg ps fname = do
|
||||
let nargs = length $ filter (not.isStatic) ps
|
||||
f = VarE $ mkName fname
|
||||
args <- sequence $ take nargs $ repeat $ newName "x"
|
||||
rsg <- [| runSubsiteGetter|]
|
||||
rsg <- [|error "runSubsiteGetter"|]
|
||||
let xps = map VarP args
|
||||
xes = map VarE args
|
||||
e' = foldl (\x y -> x `AppE` y) f xes
|
||||
e = rsg `AppE` e'
|
||||
return $ LamE xps e
|
||||
return $ rsg -- FIXME LamE xps e
|
||||
|
||||
-- | Convert the given argument into a WAI application, executable with any WAI
|
||||
-- handler. This is the same as 'toWaiAppPlain', except it includes three
|
||||
|
||||
Loading…
Reference in New Issue
Block a user