redone backend handling and config parsing
This commit is contained in:
parent
4733c3e3e2
commit
c4a1a442f3
9 changed files with 177 additions and 166 deletions
39
app/Backend/Backend.hs
Normal file
39
app/Backend/Backend.hs
Normal file
|
@ -0,0 +1,39 @@
|
|||
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
|
||||
|
||||
-- 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
|
||||
[]
|
Loading…
Add table
Add a link
Reference in a new issue