Custom monad
This commit is contained in:
@ -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
|
||||
|
Reference in New Issue
Block a user