From 8d58cc805134d305dd4ce629e13b7b7bf42019dd Mon Sep 17 00:00:00 2001 From: Michael Snoyman Date: Tue, 4 May 2010 22:11:25 +0300 Subject: [PATCH] urlRenderOverride --- Yesod/Dispatch.hs | 5 ++++- Yesod/Yesod.hs | 6 ++++++ 2 files changed, 10 insertions(+), 1 deletion(-) 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