From 729751f7420fd941eed73d6079ec02a79a808d61 Mon Sep 17 00:00:00 2001 From: Michael Snoyman Date: Wed, 30 Jun 2010 20:46:47 +0300 Subject: [PATCH] Fixed type signature in some functions in Yesod typeclass --- Yesod/Dispatch.hs | 8 ++++---- Yesod/Handler.hs | 4 ++-- Yesod/Yesod.hs | 14 +++++++------- 3 files changed, 13 insertions(+), 13 deletions(-) diff --git a/Yesod/Dispatch.hs b/Yesod/Dispatch.hs index 211ef741..30297ddf 100644 --- a/Yesod/Dispatch.hs +++ b/Yesod/Dispatch.hs @@ -246,14 +246,14 @@ toWaiApp' y segments env = do eurl = parsePathSegments site pathSegments render u = fromMaybe (fullRender (approot y) (formatPathSegments site) u) - (urlRenderOverride y u) + (urlRenderOverride u) rr <- parseWaiRequest env session' - onRequest y rr - let h = + let h = do + onRequest case eurl of Left _ -> errorHandler NotFound Right url -> do - -- FIXME auth <- isAuthorized y url + isAuthorized url >>= maybe (return ()) permissionDenied case handleSite site render url method of Nothing -> errorHandler $ BadMethod method Just h' -> h' diff --git a/Yesod/Handler.hs b/Yesod/Handler.hs index 925d4ac4..4ad0e4c1 100644 --- a/Yesod/Handler.hs +++ b/Yesod/Handler.hs @@ -364,8 +364,8 @@ badMethod = do failure $ BadMethod $ toString $ W.methodToBS $ W.requestMethod w -- | Return a 403 permission denied page. -permissionDenied :: Failure ErrorResponse m => m a -permissionDenied = failure $ PermissionDenied "Permission denied" +permissionDenied :: Failure ErrorResponse m => String -> m a +permissionDenied = failure . PermissionDenied -- | Return a 400 invalid arguments page. invalidArgs :: Failure ErrorResponse m => [(ParamName, String)] -> m a diff --git a/Yesod/Yesod.hs b/Yesod/Yesod.hs index fa9c5213..381df617 100644 --- a/Yesod/Yesod.hs +++ b/Yesod/Yesod.hs @@ -85,22 +85,22 @@ class Yesod a where |] -- | Gets called at the beginning of each request. Useful for logging. - onRequest :: a -> Request -> IO () - onRequest _ _ = return () + onRequest :: GHandler sub a () + 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 + urlRenderOverride :: Routes a -> Maybe String + urlRenderOverride _ = Nothing - -- | Determine is a request is authorized or not. + -- | Determine if a request is authorized or not. -- -- Return 'Nothing' is the request is authorized, 'Just' a message if -- unauthorized. If authentication is required, you should use a redirect; -- the Auth helper provides this functionality automatically. - isAuthorized :: a -> Routes a -> IO (Maybe String) - isAuthorized _ _ = return Nothing + isAuthorized :: Routes a -> Handler a (Maybe String) + isAuthorized _ = return Nothing -- | A type-safe, concise method of creating breadcrumbs for pages. For each -- resource, you declare the title of the page and the parent resource (if