diff --git a/app/Backend/Backend.hs b/app/Backend/Backend.hs index fceb050..8af84dd 100644 --- a/app/Backend/Backend.hs +++ b/app/Backend/Backend.hs @@ -21,9 +21,7 @@ import qualified Backend.Https as HTTPS -- 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) +-- the path of the config File. data Backend = BackendWithConfig (Wai.Application -> FilePath -> EnvM [MVar ()]) String String diff --git a/app/Main.hs b/app/Main.hs index eff0e8f..8379eff 100644 --- a/app/Main.hs +++ b/app/Main.hs @@ -41,6 +41,13 @@ defaultLogLevel = Info blockBackends :: [MVar ()] -> EnvM () blockBackends = mapM_ takeMVar +runBackend :: Wai.Application -> Either (Maybe String) Bool -> Backend -> EnvM [MVar ()] +runBackend app (Left (Just conf)) (BackendWithConfig b _ _) = b app conf +runBackend _ (Left Nothing) (BackendWithConfig _ _ _) = return [] +runBackend app (Right True) (BackendWithoutConfig b _ _) = b app +runBackend _ (Right False) (BackendWithoutConfig _ _ _) = return [] +runBackend _ _ _ = logError "Backend and parser type don't match! THIS IS A BUG" >> return [] + data CommandLineOptions = CommandLineOptions { backendOptions :: [Either (Maybe String) Bool], logSeverity :: Maybe Severity @@ -57,14 +64,6 @@ parser = CommandLineOptions <$> backendsParser <*> severityParser - -runBackend :: Wai.Application -> Either (Maybe String) Bool -> Backend -> EnvM [MVar ()] -runBackend app (Left (Just conf)) (BackendWithConfig b _ _) = b app conf -runBackend _ (Left Nothing) (BackendWithConfig _ _ _) = return [] -runBackend app (Right True) (BackendWithoutConfig b _ _) = b app -runBackend _ (Right False) (BackendWithoutConfig _ _ _) = return [] -runBackend _ _ _ = logError "Backend and parser type don't match! THIS IS A BUG" >> return [] - commandLineParser :: ParserInfo CommandLineOptions commandLineParser = info (parser <**> helper) ( fullDesc