getBy404
This commit is contained in:
parent
676a6aa6c1
commit
05fde1f464
@ -15,6 +15,7 @@ module Yesod.Yesod
|
|||||||
, YesodPersist (..)
|
, YesodPersist (..)
|
||||||
, module Database.Persist
|
, module Database.Persist
|
||||||
, get404
|
, get404
|
||||||
|
, getBy404
|
||||||
-- ** Breadcrumbs
|
-- ** Breadcrumbs
|
||||||
, YesodBreadcrumbs (..)
|
, YesodBreadcrumbs (..)
|
||||||
, breadcrumbs
|
, breadcrumbs
|
||||||
@ -392,6 +393,15 @@ get404 key = do
|
|||||||
Nothing -> lift notFound
|
Nothing -> lift notFound
|
||||||
Just res -> return res
|
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.
|
-- | 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
|
-- Built on top of 'isAuthorized'. This is useful for building page that only
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user