Commit 5e1fa932 authored by Ibnu Daru Aji's avatar Ibnu Daru Aji

configuration and custom handler.

parent 0a14c4f3
......@@ -18,6 +18,7 @@ library
ghc-options: -Wall
exposed-modules: Lib
, Types
, Conf
, Model
other-modules: Lib.Prelude
build-depends: base >= 4.7 && < 5
......
{-# LANGUAGE DeriveFunctor #-}
{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE GeneralizedNewtypeDeriving #-}
module Conf where
import Lib.Prelude
import Database.Persist.Postgresql
import Servant
import Servant.Auth.Server
data Configuration = Configuration
{ configurationPool :: ConnectionPool
, configurationJWTSettings :: JWTSettings
}
newtype CoachT m a = CoachT
{ runCoach :: ReaderT Configuration (ExceptT ServantErr m) a
} deriving ( Functor
, Applicative
, Monad
, MonadReader Configuration
, MonadError ServantErr
, MonadIO
)
type Coach = CoachT IO
coachToHandler :: Configuration -> Coach a -> Handler a
coachToHandler conf coach = Handler (runReaderT (runCoach coach) conf)
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment