{-# LANGUAGE UndecidableInstances #-}
{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE TypeFamilies #-}
{-# OPTIONS_GHC -fno-warn-warnings-deprecations #-}
module Yesod.Core
(
Yesod (..)
, YesodDispatch (..)
, YesodSubDispatch (..)
, RenderRoute (..)
, ParseRoute (..)
, RouteAttrs (..)
, YesodBreadcrumbs (..)
, breadcrumbs
, Approot (..)
, FileUpload (..)
, ErrorResponse (..)
, maybeAuthorized
, widgetToPageContent
, defaultErrorHandler
, defaultYesodMiddleware
, authorizationCheck
, AuthResult (..)
, unauthorizedI
, defaultMakeLogger
, defaultMessageLoggerSource
, defaultShouldLogIO
, formatLogMessage
, LogLevel (..)
, logDebug
, logInfo
, logWarn
, logError
, logOther
, logDebugS
, logInfoS
, logWarnS
, logErrorS
, logOtherS
, SessionBackend (..)
, customizeSessionCookies
, defaultClientSessionBackend
, envClientSessionBackend
, clientSessionBackend
, sslOnlySessions
, laxSameSiteSessions
, strictSameSiteSessions
, sslOnlyMiddleware
, clientSessionDateCacher
, loadClientSession
, Header(..)
, defaultCsrfMiddleware
, defaultCsrfSetCookieMiddleware
, csrfSetCookieMiddleware
, defaultCsrfCheckMiddleware
, csrfCheckMiddleware
, ScriptLoadPosition (..)
, BottomOfHeadAsync
, MonadHandler (..)
, MonadWidget (..)
, guessApproot
, guessApprootOr
, getApprootText
, yesodVersion
, yesodRender
, Yesod.Core.runFakeHandler
, module Yesod.Core.Internal.LiteApp
, yesodRunner
, module Yesod.Core.Content
, module Yesod.Core.Dispatch
, module Yesod.Core.Handler
, module Yesod.Core.Widget
, module Yesod.Core.Json
, module Text.Shakespeare.I18N
, module Yesod.Core.Internal.Util
, module Text.Blaze.Html
, MonadTrans (..)
, MonadIO (..)
, MonadUnliftIO (..)
, MonadResource (..)
, MonadLogger
, Application
, showIntegral
, readIntegral
, hamlet
, shamlet
, xhamlet
, HtmlUrl
, julius
, JavascriptUrl
, renderJavascriptUrl
, cassius
, lucius
, CssUrl
, renderCssUrl
) where
import Yesod.Core.Content
import Yesod.Core.Dispatch
import Yesod.Core.Handler
import Yesod.Core.Class.Handler
import Yesod.Core.Widget
import Yesod.Core.Json
import Yesod.Core.Types
import Text.Shakespeare.I18N
import Yesod.Core.Internal.Util (formatW3 , formatRFC1123 , formatRFC822)
import Text.Blaze.Html (Html, toHtml, preEscapedToMarkup)
import Control.Monad.Logger
import Control.Monad.Trans.Class (MonadTrans (..))
import Yesod.Core.Internal.Session
import Yesod.Core.Internal.Run (yesodRunner, yesodRender)
import Yesod.Core.Class.Yesod
import Yesod.Core.Class.Dispatch
import Yesod.Core.Class.Breadcrumbs
import qualified Yesod.Core.Internal.Run
import qualified Paths_yesod_core
import Data.Version (showVersion)
import Yesod.Routes.Class
import UnliftIO (MonadIO (..), MonadUnliftIO (..))
import Control.Monad.Trans.Resource (MonadResource (..))
import Yesod.Core.Internal.LiteApp
import Text.Hamlet
import Text.Cassius
import Text.Lucius
import Text.Julius
import Network.Wai (Application)
runFakeHandler :: (Yesod site, MonadIO m) =>
SessionMap
-> (site -> Logger)
-> site
-> HandlerT site IO a
-> m (Either ErrorResponse a)
runFakeHandler :: forall site (m :: * -> *) a.
(Yesod site, MonadIO m) =>
SessionMap
-> (site -> Logger)
-> site
-> HandlerT site IO a
-> m (Either ErrorResponse a)
runFakeHandler = forall site (m :: * -> *) a.
(Yesod site, MonadIO m) =>
SessionMap
-> (site -> Logger)
-> site
-> HandlerT site IO a
-> m (Either ErrorResponse a)
Yesod.Core.Internal.Run.runFakeHandler
{-# DEPRECATED runFakeHandler "import runFakeHandler from Yesod.Core.Unsafe" #-}
unauthorizedI :: (MonadHandler m, RenderMessage (HandlerSite m) msg) => msg -> m AuthResult
unauthorizedI :: forall (m :: * -> *) msg.
(MonadHandler m, RenderMessage (HandlerSite m) msg) =>
msg -> m AuthResult
unauthorizedI msg
msg = do
msg -> Text
mr <- forall (m :: * -> *) message.
(MonadHandler m, RenderMessage (HandlerSite m) message) =>
m (message -> Text)
getMessageRender
forall (m :: * -> *) a. Monad m => a -> m a
return forall a b. (a -> b) -> a -> b
$ Text -> AuthResult
Unauthorized forall a b. (a -> b) -> a -> b
$ msg -> Text
mr msg
msg
yesodVersion :: String
yesodVersion :: String
yesodVersion = Version -> String
showVersion Version
Paths_yesod_core.version
maybeAuthorized :: Yesod site
=> Route site
-> Bool
-> HandlerT site IO (Maybe (Route site))
maybeAuthorized :: forall site.
Yesod site =>
Route site -> Bool -> HandlerT site IO (Maybe (Route site))
maybeAuthorized Route site
r Bool
isWrite = do
AuthResult
x <- forall site.
Yesod site =>
Route site -> Bool -> HandlerFor site AuthResult
isAuthorized Route site
r Bool
isWrite
forall (m :: * -> *) a. Monad m => a -> m a
return forall a b. (a -> b) -> a -> b
$ if AuthResult
x forall a. Eq a => a -> a -> Bool
== AuthResult
Authorized then forall a. a -> Maybe a
Just Route site
r else forall a. Maybe a
Nothing
showIntegral :: Integral a => a -> String
showIntegral :: forall a. Integral a => a -> String
showIntegral a
x = forall a. Show a => a -> String
show (forall a b. (Integral a, Num b) => a -> b
fromIntegral a
x :: Integer)
readIntegral :: Num a => String -> Maybe a
readIntegral :: forall a. Num a => String -> Maybe a
readIntegral String
s =
case forall a. Read a => ReadS a
reads String
s of
(Integer
i, String
_):[(Integer, String)]
_ -> forall a. a -> Maybe a
Just forall a b. (a -> b) -> a -> b
$ forall a. Num a => Integer -> a
fromInteger Integer
i
[] -> forall a. Maybe a
Nothing