smaller changes not changing semantics
This commit is contained in:
parent
70ee16d202
commit
1816bd9bb5
2 changed files with 8 additions and 11 deletions
|
@ -21,9 +21,7 @@ import qualified Backend.Https as HTTPS
|
||||||
-- list of MVar is there to communicate the termination of the backend. (The main
|
-- 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)).
|
-- 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 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
|
-- the path of the config File.
|
||||||
-- and the action should not try to evaluate the FilePath.
|
|
||||||
-- type Backend = (Wai.Application -> FilePath -> IO [MVar ()],T.Text,Bool)
|
|
||||||
|
|
||||||
data Backend =
|
data Backend =
|
||||||
BackendWithConfig (Wai.Application -> FilePath -> EnvM [MVar ()]) String String
|
BackendWithConfig (Wai.Application -> FilePath -> EnvM [MVar ()]) String String
|
||||||
|
|
15
app/Main.hs
15
app/Main.hs
|
@ -41,6 +41,13 @@ defaultLogLevel = Info
|
||||||
blockBackends :: [MVar ()] -> EnvM ()
|
blockBackends :: [MVar ()] -> EnvM ()
|
||||||
blockBackends = mapM_ takeMVar
|
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 {
|
data CommandLineOptions = CommandLineOptions {
|
||||||
backendOptions :: [Either (Maybe String) Bool],
|
backendOptions :: [Either (Maybe String) Bool],
|
||||||
logSeverity :: Maybe Severity
|
logSeverity :: Maybe Severity
|
||||||
|
@ -57,14 +64,6 @@ parser = CommandLineOptions
|
||||||
<$> backendsParser
|
<$> backendsParser
|
||||||
<*> severityParser
|
<*> 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 :: ParserInfo CommandLineOptions
|
||||||
commandLineParser = info (parser <**> helper)
|
commandLineParser = info (parser <**> helper)
|
||||||
( fullDesc
|
( fullDesc
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue