aboutsummaryrefslogtreecommitdiff
path: root/src/server/Conf.hs
diff options
context:
space:
mode:
Diffstat (limited to 'src/server/Conf.hs')
-rw-r--r--src/server/Conf.hs31
1 files changed, 18 insertions, 13 deletions
diff --git a/src/server/Conf.hs b/src/server/Conf.hs
index 13d5981..a05349d 100644
--- a/src/server/Conf.hs
+++ b/src/server/Conf.hs
@@ -1,11 +1,12 @@
{-# LANGUAGE OverloadedStrings #-}
module Conf
- ( getConf
+ ( get
, Conf(..)
) where
import Data.Text (Text)
+import qualified Data.Text as T
import qualified Data.ConfigManager as Conf
import Data.Time.Clock (NominalDiffTime)
@@ -18,15 +19,19 @@ data Conf = Conf
, https :: Bool
} deriving Show
-getConf :: FilePath -> IO (Either Text Conf)
-getConf path =
- (flip fmap) (Conf.readConfig path) (\configOrError -> do
- conf <- configOrError
- Conf <$>
- Conf.lookup "hostname" conf <*>
- Conf.lookup "port" conf <*>
- Conf.lookup "signInExpiration" conf <*>
- Conf.lookup "currency" conf <*>
- Conf.lookup "noReplyMail" conf <*>
- Conf.lookup "https" conf
- )
+get :: FilePath -> IO Conf
+get path = do
+ conf <-
+ (flip fmap) (Conf.readConfig path) (\configOrError -> do
+ conf <- configOrError
+ Conf <$>
+ Conf.lookup "hostname" conf <*>
+ Conf.lookup "port" conf <*>
+ Conf.lookup "signInExpiration" conf <*>
+ Conf.lookup "currency" conf <*>
+ Conf.lookup "noReplyMail" conf <*>
+ Conf.lookup "https" conf
+ )
+ case conf of
+ Left msg -> error (T.unpack msg)
+ Right c -> return c