aboutsummaryrefslogtreecommitdiff
path: root/server/lib/Uplcg/Config.hs
diff options
context:
space:
mode:
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")