packages feed

yesod-core-1.7.0.0: test/YesodCoreTest/SubsiteFallthrough/Nested.hs

{-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE MultiParamTypeClasses #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE TemplateHaskell #-}
{-# LANGUAGE TypeFamilies #-}
{-# LANGUAGE ViewPatterns #-}
{-# OPTIONS_GHC -Wno-orphans #-}

-- | The split-out dispatch module for the fallthrough subsites' nested
-- @WrapR@ fragments. The nested handlers live here, alongside the
-- 'YesodSubDispatchNested' instances generated by 'mkNestedSubDispatchInstance'
-- — @FallOnSub@ with fallthrough enabled, @FallOffSub@ at the default.
--
-- Compiled separately from "YesodCoreTest.SubsiteFallthrough.Runtime" so the host
-- site's 'mkYesodSubDispatch' splice sees these instances via 'isInstance' and
-- delegates @WrapR@ to them; the delegated 'YesodSubDispatchNested' is what
-- routes through 'genNestedDispatchClauses' and so honours the fallthrough
-- flag baked in here.
module YesodCoreTest.SubsiteFallthrough.Nested () where

import Yesod.Core
import Yesod.Core.Dispatch
    (mkNestedSubDispatchInstance, TyArgs(..))
import Data.Text (Text)

import YesodCoreTest.SubsiteFallthrough.Data

-- Fallthrough ENABLED subsite ----------------------------------------------

getOnFooAIndexR :: SubHandlerFor FallOnSub master Text
getOnFooAIndexR = pure "onFooAIndex"

getOnFooBBarR :: SubHandlerFor FallOnSub master Text
getOnFooBBarR = pure "onFooBBar"

$(mkNestedSubDispatchInstance
    (setNestedRouteFallthrough True defaultOpts)
    "OnWrapR"
    []
    NoTyArgs
    return
    resourcesFallOnSub)

-- Fallthrough DISABLED subsite (default opts) ------------------------------

getOffFooAIndexR :: SubHandlerFor FallOffSub master Text
getOffFooAIndexR = pure "offFooAIndex"

getOffFooBBarR :: SubHandlerFor FallOffSub master Text
getOffFooBBarR = pure "offFooBBar"

$(mkNestedSubDispatchInstance
    defaultOpts
    "OffWrapR"
    []
    NoTyArgs
    return
    resourcesFallOffSub)