yesod-core-1.4.12: Creation of type-safe, RESTful web applications.

Safe HaskellNone



This is designed to be used as

qualified import Yesod.Core.Unsafe as Unsafe

This serves as a reminder that the functions are unsafe to use in many situations.



runFakeHandler :: (Yesod site, MonadIO m) => SessionMap -> (site -> Logger) -> site -> HandlerT site IO a -> m (Either ErrorResponse a) Source

Run a HandlerT 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 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 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 session, cookies or headers. We only return you the HandlerT's return value.

fakeHandlerGetLogger :: (Yesod site, MonadIO m) => (site -> Logger) -> site -> HandlerT site IO a -> m a Source

designed to be used as

unsafeHandler = Unsafe.fakeHandlerGetLogger appLogger