{-# LANGUAGE DeriveGeneric #-} {-# LANGUAGE LambdaCase #-} {-# LANGUAGE OverloadedStrings #-} {- | This module contains the configuration data structures. -} module Network.Legion.Discovery.Config ( Config(..), ) where import Canteven.Log.MonadLog (LoggingConfig) import Data.Aeson (FromJSON, Value(Object), (.:), parseJSON) import GHC.Generics (Generic) import Network.Wai.Handler.Warp (Port) data Config = Config { servicePort :: Port, ekgPort :: Port, logging :: LoggingConfig } deriving (Generic) instance FromJSON Config where parseJSON v@(Object config) = Config <$> config .: "servicePort" <*> config .: "ekgPort" <*> parseJSON v parseJSON value = fail $ "Couldn't parse config from " ++ show value