    module Web.Scotty.Trans.Lazy where

    import Control.Monad (join)
    import Control.Monad.IO.Class
    import Data.Bifunctor (bimap)
    import qualified Data.Text.Lazy as T

    import Network.HTTP.Types (Status)

    import qualified Web.Scotty.Action as Base
    import Web.Scotty.Internal.Types

    -- | Throw a "500 Server Error" 'StatusError', which can be caught with 'rescue'.
    --
    -- Uncaught exceptions turn into HTTP 500 responses.
    raise :: (MonadIO m) =>
             T.Text -- ^ Error text
          -> ActionT m a
    raise :: forall (m :: * -> *) a. MonadIO m => Text -> ActionT m a
    raise  = Text -> ActionT m a
    forall (m :: * -> *) a. MonadIO m => Text -> ActionT m a
    Base.raise (Text -> ActionT m a) -> (Text -> Text) -> Text -> ActionT m a
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . Text -> Text
    T.toStrict
    {-# DEPRECATED raise "Throw an exception instead" #-}

    -- | Throw a 'StatusError' exception that has an associated HTTP error code and can be caught with 'rescue'.
    --
    -- Uncaught exceptions turn into HTTP responses corresponding to the given status.
    raiseStatus :: Monad m => Status -> T.Text -> ActionT m a
    raiseStatus :: forall (m :: * -> *) a. Monad m => Status -> Text -> ActionT m a
    raiseStatus Status
    s = Status -> Text -> ActionT m a
    forall (m :: * -> *) a. Monad m => Status -> Text -> ActionT m a
    Base.raiseStatus Status
    s (Text -> ActionT m a) -> (Text -> Text) -> Text -> ActionT m a
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . Text -> Text
    T.toStrict
    {-# DEPRECATED raiseStatus "Use status, text, and finish instead" #-}

    -- | Redirect to given URL. Like throwing an uncatchable exception. Any code after the call to redirect
    -- will not be run.
    --
    -- > redirect "http://www.google.com"
    --
    -- OR
    --
    -- > redirect "/foo/bar"
    redirect :: (Monad m) => T.Text -> ActionT m a
    redirect :: forall (m :: * -> *) a. Monad m => Text -> ActionT m a
    redirect = Text -> ActionT m a
    forall (m :: * -> *) a. Monad m => Text -> ActionT m a
    Base.redirect (Text -> ActionT m a) -> (Text -> Text) -> Text -> ActionT m a
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . Text -> Text
    T.toStrict

    -- | Get a request header. Header name is case-insensitive.
    header :: (Monad m) => T.Text -> ActionT m (Maybe T.Text)
    header :: forall (m :: * -> *). Monad m => Text -> ActionT m (Maybe Text)
    header Text
    h = (Text -> Text) -> Maybe Text -> Maybe Text
    forall a b. (a -> b) -> Maybe a -> Maybe b
    forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
    fmap Text -> Text
    T.fromStrict (Maybe Text -> Maybe Text)
    -> ActionT m (Maybe Text) -> ActionT m (Maybe Text)
    forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
    <$> Text -> ActionT m (Maybe Text)
    forall (m :: * -> *). Monad m => Text -> ActionT m (Maybe Text)
    Base.header (Text -> Text
    T.toStrict Text
    h)

    -- | Get all the request headers. Header names are case-insensitive.
    headers :: (Monad m) => ActionT m [(T.Text, T.Text)]
    headers :: forall (m :: * -> *). Monad m => ActionT m [(Text, Text)]
    headers = ((Text, Text) -> (Text, Text)) -> [(Text, Text)] -> [(Text, Text)]
    forall a b. (a -> b) -> [a] -> [b]
    map (((Text -> Text) -> (Text -> Text) -> (Text, Text) -> (Text, Text))
    -> (Text -> Text) -> (Text, Text) -> (Text, Text)
    forall (m :: * -> *) a. Monad m => m (m a) -> m a
    join (Text -> Text) -> (Text -> Text) -> (Text, Text) -> (Text, Text)
    forall a b c d. (a -> b) -> (c -> d) -> (a, c) -> (b, d)
    forall (p :: * -> * -> *) a b c d.
    Bifunctor p =>
    (a -> b) -> (c -> d) -> p a c -> p b d
    bimap Text -> Text
    T.fromStrict) ([(Text, Text)] -> [(Text, Text)])
    -> ActionT m [(Text, Text)] -> ActionT m [(Text, Text)]
    forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
    <$> ActionT m [(Text, Text)]
    forall (m :: * -> *). Monad m => ActionT m [(Text, Text)]
    Base.headers

    -- | Add to the response headers. Header names are case-insensitive.
    addHeader :: MonadIO m => T.Text -> T.Text -> ActionT m ()
    addHeader :: forall (m :: * -> *). MonadIO m => Text -> Text -> ActionT m ()
    addHeader Text
    k Text
    v = Text -> Text -> ActionT m ()
    forall (m :: * -> *). MonadIO m => Text -> Text -> ActionT m ()
    Base.addHeader (Text -> Text
    T.toStrict Text
    k) (Text -> Text
    T.toStrict Text
    v)

    -- | Set one of the response headers. Will override any previously set value for that header.
    -- Header names are case-insensitive.
    setHeader :: MonadIO m => T.Text -> T.Text -> ActionT m ()
    setHeader :: forall (m :: * -> *). MonadIO m => Text -> Text -> ActionT m ()
    setHeader Text
    k Text
    v = Text -> Text -> ActionT m ()
    forall (m :: * -> *). MonadIO m => Text -> Text -> ActionT m ()
    Base.addHeader (Text -> Text
    T.toStrict Text
    k) (Text -> Text
    T.toStrict Text
    v)

    text :: (MonadIO m) => T.Text -> ActionT m ()
    text :: forall (m :: * -> *). MonadIO m => Text -> ActionT m ()
    text = Text -> ActionT m ()
    forall (m :: * -> *). MonadIO m => Text -> ActionT m ()
    Base.textLazy

    html :: (MonadIO m) => T.Text -> ActionT m ()
    html :: forall (m :: * -> *). MonadIO m => Text -> ActionT m ()
    html = Text -> ActionT m ()
    forall (m :: * -> *). MonadIO m => Text -> ActionT m ()
    Base.htmlLazy