aboutsummaryrefslogtreecommitdiff
path: root/server/lib/Uplcg/Config.hs
diff options
context:
space:
mode:
authorJasper Van der Jeugt2020-08-16 12:33:35 +0200
committerJasper Van der Jeugt2020-08-16 12:33:35 +0200
commit915aa0a168dce36013193be1c76a8448e3417556 (patch)
treeb2e669581db6ab32b8851f0436f1ed6636e8e870 /server/lib/Uplcg/Config.hs
parente0555c0fc44404befef4eeb51bb7745a79cac1a5 (diff)
parentd543ef8b1f68a23f9bc3706363fc3807ccbabf30 (diff)
Merge branch 'list-rooms' into main
Diffstat (limited to 'server/lib/Uplcg/Config.hs')
-rw-r--r--server/lib/Uplcg/Config.hs21
1 files changed, 21 insertions, 0 deletions
diff --git a/server/lib/Uplcg/Config.hs b/server/lib/Uplcg/Config.hs
new file mode 100644
index 0000000..9197d97
--- /dev/null
+++ b/server/lib/Uplcg/Config.hs
@@ -0,0 +1,21 @@
+module Uplcg.Config
+ ( Config (..)
+ , fromEnv
+ ) where
+
+import qualified Data.Text as T
+import System.Environment (getEnv)
+import Uplcg.BaseUrl (BaseUrl)
+import qualified Uplcg.BaseUrl as BaseUrl
+
+data Config = Config
+ { cHostname :: String
+ , cPort :: Int
+ , cBaseUrl :: BaseUrl
+ } deriving (Show)
+
+fromEnv :: IO Config
+fromEnv = Config
+ <$> getEnv "UPLCG_HOSTNAME"
+ <*> (read <$> getEnv "UPLCG_PORT")
+ <*> (BaseUrl.parse . T.pack <$> getEnv "UPLCG_BASE")