| Safe Haskell | None |
|---|---|
| Language | Haskell2010 |
Yam.Internal
Contents
Synopsis
- startYam :: forall api. (HasSwagger api, HasServer api '[Env]) => AppConfig -> SwaggerConfig -> LogConfig -> Bool -> Version -> [AppMiddleware] -> Proxy api -> ServerT api App -> IO ()
- start :: forall api. (HasSwagger api, HasServer api '[Env]) => Properties -> Version -> [AppMiddleware] -> Proxy api -> ServerT api App -> IO ()
- type App = AppM IO
- withLogger :: Text -> LogConfig -> LoggingT IO a -> IO a
- setLogger :: LogFunc -> Env -> Env
- setExtendLog :: (Text -> Text) -> Env -> Env
- extensionLogKey :: Key Text
- throwS :: (HasCallStack, MonadIO m) => ServantErr -> Text -> AppM m a
- data LogConfig = LogConfig {
- bufferSize :: Word16
- file :: FilePath
- maxSize :: Word32
- rotateHistory :: Word16
- level :: LogLevel
- data AppConfig = AppConfig {}
- data Env = Env {}
- getAttr :: Key a -> Env -> Maybe a
- setAttr :: Key a -> a -> Env -> Env
- reqAttr :: Default a => Key a -> Env -> a
- data AppM m a
- runAppM :: Env -> AppM m a -> m a
- withAppM :: MonadIO m => (Env -> Env) -> AppM m a -> AppM m a
- askApp :: Monad m => AppM m AppConfig
- askAttr :: MonadIO m => Key a -> AppM m (Maybe a)
- withAttr :: MonadIO m => Key a -> a -> AppM m b -> AppM m b
- requireAttr :: MonadIO m => Key a -> AppM m a
- newtype AppMiddleware = AppMiddleware {}
- simpleAppMiddleware :: HasCallStack => (Bool, Text) -> Key a -> a -> AppMiddleware
- simpleWebMiddleware :: HasCallStack => (Bool, Text) -> Middleware -> AppMiddleware
- type LogFunc = Loc -> LogSource -> LogLevel -> LogStr -> IO ()
- randomString :: Int -> IO Text
- showText :: Show a => a -> Text
- defJson :: FromJSON a => a
- type Key = Key RealWorld
- newKey :: IO (Key a)
- type Middleware = Application -> Application
- data Request
- lift :: (MonadTrans t, Monad m) => m a -> t m a
- when :: Applicative f => Bool -> f () -> f ()
- class Default a where
- def :: a
- data Text
- pack :: String -> Text
- encodeUtf8 :: Text -> ByteString
- decodeUtf8 :: ByteString -> Text
- class Monad m => MonadIO (m :: Type -> Type)
- liftIO :: MonadIO m => IO a -> m a
- withReaderT :: (r' -> r) -> ReaderT r m a -> ReaderT r' m a
- module Control.Monad.Logger.CallStack
- module Data.Maybe
- module Servant
- module Data.Aeson
- module Data.Word
- module Data.Function
- module Data.Version
- data SwaggerConfig = SwaggerConfig {}
- readConf :: (Default a, FromProperties a) => Text -> Properties -> a
Application Functions
startYam :: forall api. (HasSwagger api, HasServer api '[Env]) => AppConfig -> SwaggerConfig -> LogConfig -> Bool -> Version -> [AppMiddleware] -> Proxy api -> ServerT api App -> IO () Source #
start :: forall api. (HasSwagger api, HasServer api '[Env]) => Properties -> Version -> [AppMiddleware] -> Proxy api -> ServerT api App -> IO () Source #
Logger Function
throwS :: (HasCallStack, MonadIO m) => ServantErr -> Text -> AppM m a Source #
Constructors
| LogConfig | |
Fields
| |
Environment
Constructors
| Env | |
Fields
| |
AppM Monad
Instances
| Monad m => MonadReader Env (AppM m) Source # | |
| MonadTrans (AppM :: (Type -> Type) -> Type -> Type) Source # | |
| Monad m => Monad (AppM m) Source # | |
| Functor m => Functor (AppM m) Source # | |
| Applicative m => Applicative (AppM m) Source # | |
| MonadIO m => MonadIO (AppM m) Source # | |
| MonadUnliftIO m => MonadUnliftIO (AppM m) Source # | |
| MonadIO m => MonadLogger (AppM m) Source # | |
Defined in Yam.Logger | |
| MonadIO m => MonadLoggerIO (AppM m) Source # | |
Defined in Yam.Logger | |
Application Middleware
newtype AppMiddleware Source #
Application Middleware
Constructors
| AppMiddleware | |
Instances
| Semigroup AppMiddleware Source # | |
Defined in Yam.Types Methods (<>) :: AppMiddleware -> AppMiddleware -> AppMiddleware # sconcat :: NonEmpty AppMiddleware -> AppMiddleware # stimes :: Integral b => b -> AppMiddleware -> AppMiddleware # | |
| Monoid AppMiddleware Source # | |
Defined in Yam.Types Methods mempty :: AppMiddleware # mappend :: AppMiddleware -> AppMiddleware -> AppMiddleware # mconcat :: [AppMiddleware] -> AppMiddleware # | |
simpleAppMiddleware :: HasCallStack => (Bool, Text) -> Key a -> a -> AppMiddleware Source #
Simple AppMiddleware
simpleWebMiddleware :: HasCallStack => (Bool, Text) -> Middleware -> AppMiddleware Source #
Utilities
Reexport Functions
type Middleware = Application -> Application #
Middleware is a component that sits between the server and application. It can do such tasks as GZIP encoding or response caching. What follows is the general definition of middleware, though a middleware author should feel free to modify this.
As an example of an alternate type for middleware, suppose you write a function to load up session information. The session information is simply a string map \[(String, String)\]. A logical type signature for this middleware might be:
loadSession :: ([(String, String)] -> Application) -> Application
Here, instead of taking a standard Application as its first argument, the
middleware takes a function which consumes the session information as well.
Information on the request sent by the client. This abstracts away the details of the underlying implementation.
Instances
| Show Request | |
| MonadReader Request DelayedIO | |
lift :: (MonadTrans t, Monad m) => m a -> t m a #
Lift a computation from the argument monad to the constructed monad.
when :: Applicative f => Bool -> f () -> f () #
Conditional execution of Applicative expressions. For example,
when debug (putStrLn "Debugging")
will output the string Debugging if the Boolean value debug
is True, and otherwise do nothing.
A class for types with a default value.
Minimal complete definition
Nothing
Instances
A space efficient, packed, unboxed Unicode text type.
Instances
encodeUtf8 :: Text -> ByteString #
Encode text using UTF-8 encoding.
decodeUtf8 :: ByteString -> Text #
Decode a ByteString containing UTF-8 encoded text that is known
to be valid.
If the input contains any invalid UTF-8 data, an exception will be
thrown that cannot be caught in pure code. For more control over
the handling of invalid data, use decodeUtf8' or
decodeUtf8With.
class Monad m => MonadIO (m :: Type -> Type) #
Monads in which IO computations may be embedded.
Any monad built by applying a sequence of monad transformers to the
IO monad will be an instance of this class.
Instances should satisfy the following laws, which state that liftIO
is a transformer of monads:
Minimal complete definition
Instances
Arguments
| :: (r' -> r) | The function to modify the environment. |
| -> ReaderT r m a | Computation to run in the modified environment. |
| -> ReaderT r' m a |
Execute a computation in a modified environment
(a more general version of local).
runReaderT(withReaderTf m) =runReaderTm . f
module Data.Maybe
module Servant
module Data.Aeson
module Data.Word
module Data.Function
module Data.Version
data SwaggerConfig Source #
Instances
| Eq SwaggerConfig Source # | |
Defined in Yam.Swagger Methods (==) :: SwaggerConfig -> SwaggerConfig -> Bool # (/=) :: SwaggerConfig -> SwaggerConfig -> Bool # | |
| Show SwaggerConfig Source # | |
Defined in Yam.Swagger Methods showsPrec :: Int -> SwaggerConfig -> ShowS # show :: SwaggerConfig -> String # showList :: [SwaggerConfig] -> ShowS # | |
| FromJSON SwaggerConfig Source # | |
Defined in Yam.Swagger Methods parseJSON :: Value -> Parser SwaggerConfig # parseJSONList :: Value -> Parser [SwaggerConfig] # | |
| Default SwaggerConfig Source # | |
Defined in Yam.Swagger Methods def :: SwaggerConfig # | |
Utilities
readConf :: (Default a, FromProperties a) => Text -> Properties -> a Source #