Custom monad

This commit is contained in:
2018-08-02 22:32:23 +03:00
parent 1e088afce4
commit 6d08e9dad4
5 changed files with 23 additions and 7 deletions

View File

@ -13,15 +13,18 @@ module Server where
import qualified API as API
import Servant
import Types
import ClassyPrelude hiding (Handler)
import Control.Monad.Logger
import Control.Monad.Except
type API = API.API :<|> "static" :> Raw
handler :: ServerT API Handler
handler = API.handler :<|> serveDirectoryFileServer "static"
server :: Application
server = serve api handler
server :: App -> Application
server app = serve api (enter server' API.handler :<|> serveDirectoryFileServer "static")
where
server' :: AppM :~> Servant.Handler
server' = NT (Handler . ExceptT . try . (`runReaderT` app) . (runFileLoggingT "logs/server.log"))
api :: Proxy API
api = Proxy