44 lines
1.6 KiB
Haskell
44 lines
1.6 KiB
Haskell
module Backend.Backend where
|
|
|
|
import Control.Concurrent.MVar
|
|
import qualified Network.Wai as Wai
|
|
|
|
#ifdef HTTP_SUPPORT
|
|
import qualified Backend.Http as HTTP
|
|
#endif
|
|
#ifdef HTTPS_SUPPORT
|
|
import qualified Backend.Https as HTTPS
|
|
#endif
|
|
#ifdef FASTCGI_SUPPORT
|
|
import qualified Backend.FastCGI as FASTCGI
|
|
#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. If the Bool is False there are no guarantees on the FilePath
|
|
-- and the action should not try to evaluate the FilePath.
|
|
-- type Backend = (Wai.Application -> FilePath -> IO [MVar ()],T.Text,Bool)
|
|
|
|
data Backend =
|
|
BackendWithConfig (Wai.Application -> FilePath -> IO [MVar ()]) String String
|
|
| BackendWithoutConfig (Wai.Application -> IO [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
|
|
#ifdef FASTCGI_SUPPORT
|
|
BackendWithoutConfig FASTCGI.forkFastCGIBackend "fastcgi" "Deploy with fastcgi" :
|
|
#endif
|
|
[]
|