tickLeisteServer/app/Main.hs
2020-10-06 13:03:36 +02:00

50 lines
1.2 KiB
Haskell

module Main where
-- TODO:
-- We need some logic to compile with different backends. Right now we only
-- support warp. But a (fast) cgi backend would be nice too.
-- TODO:
-- We need some way too configure things, like the port we run on.
-- see Network.Wai.Handler.Warp.Settings and Network.Wai.Handler.Warp.runSettings
import Control.Concurrent.MVar
import WaiApp
import qualified Colog as Log
#ifdef HTTP_SUPPORT
import qualified Network.Wai.Handler.Warp as HTTP
#endif
#ifdef HTTPS_SUPPORT
import qualified Network.Wai.Handler.WarpTLS as HTTPS
import qualified Network.Wai.Handler.Warp as HTTP
#endif
#ifdef FASTCGI_SUPPORT
import qualified Network.Wai.Handler.FastCGI as FastCGI
#endif
#ifdef CGI_SUPPORT
import qualified Network.Wai.Handler.CGI as CGI
#endif
logAction :: Log.LogAction IO Log.Message
logAction = undefined
main :: IO ()
main = do
serverState <- newMVar newServerState
#ifdef HTTP_SUPPORT
HTTP.runSettings HTTP.defaultSettings $ waiApplication logAction serverState
#endif
#ifdef HTTPS_SUPPORT
HTTPS.runTLS HTTPS.defaultTlsSettings HTTP.defaultSettings $ waiApplication serverState
#endif
#ifdef FASTCGI_SUPPORT
FastCGI.run $ waiApplication serverState
#endif
#ifdef CGI_SUPPORT
CGI.run $ waiApplication serverState
#endif
return ()