summaryrefslogtreecommitdiff
path: root/fig-web/main/Main.hs
diff options
context:
space:
mode:
Diffstat (limited to 'fig-web/main/Main.hs')
-rw-r--r--fig-web/main/Main.hs25
1 files changed, 20 insertions, 5 deletions
diff --git a/fig-web/main/Main.hs b/fig-web/main/Main.hs
index 890c010..926685c 100644
--- a/fig-web/main/Main.hs
+++ b/fig-web/main/Main.hs
@@ -6,13 +6,25 @@ import Fig.Prelude
import Options.Applicative
-import Fig.Web
import Fig.Web.Utils
+import qualified Fig.Web as Public
+import qualified Fig.Web.Secure as Secure
+
+data Command
+ = Public
+ | Secure
+
+parseCommand :: Parser Command
+parseCommand = subparser $ mconcat
+ [ command "public" $ info (pure Public) (progDesc "Launch the public web server")
+ , command "secure" $ info (pure Secure) (progDesc "Launch the private web server (intended to be run behind authentication proxy)")
+ ]
data Opts = Opts
- { busHost :: Text
- , busPort :: Text
- , config :: FilePath
+ { busHost :: !Text
+ , busPort :: !Text
+ , config :: !FilePath
+ , command :: !Command
}
parseOpts :: Parser Opts
@@ -20,6 +32,7 @@ parseOpts = do
busHost <- strOption (long "bus-host" <> metavar "HOST" <> help "Address of message bus" <> value "localhost")
busPort <- strOption (long "bus-port" <> metavar "PORT" <> help "Message bus port" <> showDefault <> value "32050")
config <- strOption (long "config" <> metavar "PATH" <> help "Path to config file" <> showDefault <> value "fig-web.toml")
+ command <- parseCommand
pure Opts{..}
main :: IO ()
@@ -29,4 +42,6 @@ main = do
<> header "fig-web - public-facing web applications"
)
cfg <- loadConfig opts.config
- server cfg (opts.busHost, opts.busPort)
+ case cfg.command of
+ Public -> Public.server cfg (opts.busHost, opts.busPort)
+ Secure -> Secure.server cfg (opts.busHost, opts.busPort)