Merge pull request #1703 from jeffhappily/update-docs-for-handlert

Replace HandlerT with HandlerFor in the documentation
This commit is contained in:
Michael Snoyman 2020-11-08 12:49:26 +02:00 committed by GitHub
commit 0325a24826
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
8 changed files with 24 additions and 16 deletions

View File

@ -1,5 +1,9 @@
# ChangeLog for yesod-core
## 1.6.18.6
* Update documentation from `HandlerT` to `HandlerFor` [#1703](https://github.com/yesodweb/yesod/pull/1703)
## 1.6.18.5
Document `ErrorResponse` [#1698](https://github.com/yesodweb/yesod/pull/1698)

View File

@ -1464,8 +1464,8 @@ respond ct = return . TypedContent ct . toContent
-- | Use a @Source@ for the response body.
--
-- Note that, for ease of use, the underlying monad is a @HandlerT@. This
-- implies that you can run any @HandlerT@ action. However, since a streaming
-- Note that, for ease of use, the underlying monad is a @HandlerFor@. This
-- implies that you can run any @HandlerFor@ action. However, since a streaming
-- response occurs after the response headers have already been sent, some
-- actions make no sense here. For example: short-circuit responses, setting
-- headers, changing status codes, etc.
@ -1476,8 +1476,8 @@ respondSource :: ContentType
-> HandlerFor site TypedContent
respondSource ctype src = HandlerFor $ \hd ->
-- Note that this implementation relies on the fact that the ResourceT
-- environment provided by the server is the same one used in HandlerT.
-- This is a safe assumption assuming the HandlerT is run correctly.
-- environment provided by the server is the same one used in HandlerFor.
-- This is a safe assumption assuming the HandlerFor is run correctly.
return $ TypedContent ctype $ ContentSource
$ transPipe (lift . flip unHandlerFor hd) src

View File

@ -181,7 +181,7 @@ evalFallback contents val = catchAny
(fmap ((mempty, ) . HCError) . toErrorHandler)
-- | Function used internally by Yesod in the process of converting a
-- 'HandlerT' into an 'Application'. Should not be needed by users.
-- 'HandlerFor' into an 'Application'. Should not be needed by users.
runHandler :: ToTypedContent c
=> RunHandlerEnv site site
-> HandlerFor site c
@ -216,26 +216,26 @@ safeEh log' er req = do
(toContent ("Internal Server Error" :: S.ByteString))
(reqSession req)
-- | Run a 'HandlerT' completely outside of Yesod. This
-- | Run a 'HandlerFor' completely outside of Yesod. This
-- function comes with many caveats and you shouldn't use it
-- unless you fully understand what it's doing and how it works.
--
-- As of now, there's only one reason to use this function at
-- all: in order to run unit tests of functions inside 'HandlerT'
-- all: in order to run unit tests of functions inside 'HandlerFor'
-- but that aren't easily testable with a full HTTP request.
-- Even so, it's better to use @wai-test@ or @yesod-test@ instead
-- of using this function.
--
-- This function will create a fake HTTP request (both @wai@'s
-- 'Request' and @yesod@'s 'Request') and feed it to the
-- @HandlerT@. The only useful information the @HandlerT@ may
-- @HandlerFor@. The only useful information the @HandlerFor@ may
-- get from the request is the session map, which you must supply
-- as argument to @runFakeHandler@. All other fields contain
-- fake information, which means that they can be accessed but
-- won't have any useful information. The response of the
-- @HandlerT@ is completely ignored, including changes to the
-- @HandlerFor@ is completely ignored, including changes to the
-- session, cookies or headers. We only return you the
-- @HandlerT@'s return value.
-- @HandlerFor@'s return value.
runFakeHandler :: (Yesod site, MonadIO m) =>
SessionMap
-> (site -> Logger)

View File

@ -231,7 +231,7 @@ data GHState = GHState
-- | An extension of the basic WAI 'W.Application' datatype to provide extra
-- features needed by Yesod. Users should never need to use this directly, as
-- the 'HandlerT' monad and template haskell code should hide it away.
-- the 'HandlerFor' monad and template haskell code should hide it away.
type YesodApp = YesodRequest -> ResourceT IO YesodResponse
-- | A generic widget, allowing specification of both the subsite and master
@ -473,7 +473,7 @@ instance MonadLogger (WidgetFor site) where
instance MonadLoggerIO (WidgetFor site) where
askLoggerIO = WidgetFor $ return . rheLog . handlerEnv . wdHandler
-- Instances for HandlerT
-- Instances for HandlerFor
instance Applicative (HandlerFor site) where
pure = HandlerFor . const . return
(<*>) = ap

View File

@ -1,5 +1,5 @@
name: yesod-core
version: 1.6.18.5
version: 1.6.18.6
license: MIT
license-file: LICENSE
author: Michael Snoyman <michael@snoyman.com>

View File

@ -1,3 +1,7 @@
## 1.6.0.1
* Update documentation from `HandlerT` to `HandlerFor` [#1703](https://github.com/yesodweb/yesod/pull/1703)
## 1.6.0
* Upgrade to yesod-core 1.6.0

View File

@ -63,9 +63,9 @@ sourceToSource src =
Just x -> yield (Chunk x) >> yield Flush
-- | Return a Server-Sent Event stream given a 'HandlerT' action
-- | Return a Server-Sent Event stream given a 'HandlerFor' action
-- that is repeatedly called. A state is threaded for the action
-- so that it may avoid using @IORefs@. The @HandlerT@ action
-- so that it may avoid using @IORefs@. The @HandlerFor@ action
-- may sleep or block while waiting for more data. The HTTP
-- socket is flushed after every list of simultaneous events.
-- The connection is closed as soon as an 'ES.CloseEvent' is

View File

@ -1,5 +1,5 @@
name: yesod-eventsource
version: 1.6.0
version: 1.6.0.1
license: MIT
license-file: LICENSE
author: Felipe Lessa <felipe.lessa@gmail.com>