This commit is contained in:
Michael Snoyman 2010-12-20 19:00:30 +02:00
parent 676a6aa6c1
commit 05fde1f464

View File

@ -15,6 +15,7 @@ module Yesod.Yesod
, YesodPersist (..)
, module Database.Persist
, get404
, getBy404
-- ** Breadcrumbs
, YesodBreadcrumbs (..)
, breadcrumbs
@ -392,6 +393,15 @@ get404 key = do
Nothing -> lift notFound
Just res -> return res
getBy404 :: (PersistBackend (t m), PersistEntity val, Monad (t m),
Failure ErrorResponse m, MonadTrans t)
=> Unique val -> t m (Key val, val)
getBy404 ukey = do
mres <- getBy ukey
case mres of
Nothing -> lift notFound
Just res -> return res
-- | Return the same URL if the user is authorized to see it.
--
-- Built on top of 'isAuthorized'. This is useful for building page that only