diff --git a/Yesod/Handler.hs b/Yesod/Handler.hs index e9d9a4f4..608ac2aa 100644 --- a/Yesod/Handler.hs +++ b/Yesod/Handler.hs @@ -50,6 +50,7 @@ module Yesod.Handler , sendFile , sendResponse , sendResponseStatus + , sendResponseCreated -- * Setting headers , setCookie , deleteCookie @@ -441,6 +442,13 @@ sendResponseStatus :: HasReps c => W.Status -> c -> GHandler s m a sendResponseStatus s = GHandler . lift . throwMEither . HCContent s . chooseRep +-- | Send a 201 "Created" response with the given route as the Location +-- response header. +sendResponseCreated :: Route m -> GHandler s m a +sendResponseCreated url = do + r <- getUrlRender + GHandler $ lift $ throwMEither $ HCCreated $ r url + -- | Return a 404 not found page. Also denotes no handler available. notFound :: Failure ErrorResponse m => m a notFound = failure NotFound diff --git a/yesod.cabal b/yesod.cabal index 3c70c6c1..96a71620 100644 --- a/yesod.cabal +++ b/yesod.cabal @@ -1,5 +1,5 @@ name: yesod -version: 0.6.5 +version: 0.6.6 license: BSD3 license-file: LICENSE author: Michael Snoyman