diff --git a/Yesod/Dispatch.hs b/Yesod/Dispatch.hs index b941a2eb..19369a09 100644 --- a/Yesod/Dispatch.hs +++ b/Yesod/Dispatch.hs @@ -122,7 +122,10 @@ toWaiApp' y resource session' env = do types = httpAccept env pathSegments = filter (not . null) $ cleanupSegments resource eurl = quasiParse site pathSegments - render = fullRender (approot y) site + render u = + case urlRenderOverride y u of + Nothing -> fullRender (approot y) site u + Just s -> s rr <- parseWaiRequest env session' onRequest y rr let ya = case eurl of diff --git a/Yesod/Yesod.hs b/Yesod/Yesod.hs index a0b4d56f..d70ef4a1 100644 --- a/Yesod/Yesod.hs +++ b/Yesod/Yesod.hs @@ -78,6 +78,12 @@ class YesodSite a => Yesod a where onRequest :: a -> Request -> IO () onRequest _ _ = return () + -- | Override the rendering function for a particular URL. One use case for + -- this is to offload static hosting to a different domain name to avoid + -- sending cookies. + urlRenderOverride :: a -> Routes a -> Maybe String + urlRenderOverride _ _ = Nothing + -- | Apply the default layout ('defaultLayout') to the given title and body. applyLayout :: Yesod master => String -- ^ title