Replace HandlerT with HandlerFor in the documentation
This commit is contained in:
parent
6a40abf033
commit
de375e26de
@ -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
|
||||
|
||||
|
||||
@ -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)
|
||||
|
||||
@ -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
|
||||
|
||||
@ -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
|
||||
|
||||
Loading…
Reference in New Issue
Block a user