{-# LANGUAGE CPP #-} module Backend.Backend where import Control.Concurrent.MVar import qualified Network.Wai as Wai import Environment #ifdef HTTP_SUPPORT import qualified Backend.Http as HTTP #endif #ifdef HTTPS_SUPPORT import qualified Backend.Https as HTTPS #endif -- maybe we want a String instead of T.Text depends on -- the argument parser -- A backend consists of three things, The backend action, a Text to be -- used as the command line option Flag, and a Bool if it has a config file. -- -- The backend action must be non blocking and fork the backend, the returned -- list of MVar is there to communicate the termination of the backend. (The main -- threat will wait till all MVar are present (not neccesarry at once)). -- The action takes two parameter, the application the backend should run and -- the path of the config File. data Backend = BackendWithConfig (Wai.Application -> FilePath -> EnvM [MVar ()]) String String | BackendWithoutConfig (Wai.Application -> EnvM [MVar ()]) String String backends :: [Backend] backends = #ifdef HTTP_SUPPORT BackendWithConfig HTTP.forkHttpBackend "http" "Host as a simple http server, using Warp" : #endif #ifdef HTTPS_SUPPORT BackendWithConfig HTTPS.forkHttpsBackend "https" "Host as as simple https server, using Warp" : #endif []