aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorstuebinm2024-05-21 20:24:36 +0200
committerstuebinm2024-05-21 20:24:36 +0200
commit4fe7828e2364c5daeb70765ecfb1513b01bfb14e (patch)
tree48af094d78590c23c78b52c4caead23a351eddbe
parentae2fdbf72745ac46116c70f8435dacd7c227225f (diff)
Config: fix OsPath values
my annoyance with conferer increases. It should really, /really/ be a compile error if a thing used in the config does not have a FromConfig instance. Or at least the documentation should mention that in such cases it will simply always take the default value without telling anyone, instead of just saying "the generic instance has reasonable defaults" (well, /which/ defaults?)
-rw-r--r--config.yaml.sample2
-rw-r--r--lib/Config.hs9
2 files changed, 8 insertions, 3 deletions
diff --git a/config.yaml.sample b/config.yaml.sample
index c785144..41072b0 100644
--- a/config.yaml.sample
+++ b/config.yaml.sample
@@ -2,7 +2,7 @@
dbstring: "dbname=tracktrain"
gtfs: "gtfs.zip"
-zoneinfoPath: "/etc/zoneinfo/"
+zoneinfopath: "/etc/zoneinfo/"
assets: ./assets
diff --git a/lib/Config.hs b/lib/Config.hs
index ef90fc1..4c8e3fd 100644
--- a/lib/Config.hs
+++ b/lib/Config.hs
@@ -2,15 +2,17 @@
{-# LANGUAGE RecordWildCards #-}
module Config (UffdConfig(..), ServerConfig(..), LoggingConfig(..)) where
-import Conferer (DefaultConfig (configDef))
+import Conferer (DefaultConfig (configDef), fetch,
+ unsafeFetchKey)
import Conferer.FromConfig
import Conferer.FromConfig.Warp ()
import Data.ByteString (ByteString)
import Data.Functor ((<&>))
import Data.Text (Text)
+import qualified Data.Text as T
import GHC.Generics (Generic)
import Network.Wai.Handler.Warp (Settings)
-import System.OsPath (OsPath, osp)
+import System.OsPath (OsPath, encodeUtf, osp)
import URI.ByteString
data UffdConfig = UffdConfig
@@ -39,6 +41,9 @@ data LoggingConfig = LoggingConfig
instance FromConfig ServerConfig
+instance FromConfig OsPath where
+ fromConfig = fetchFromConfigWith (encodeUtf . T.unpack)
+
instance DefaultConfig ServerConfig where
configDef = ServerConfig
{ serverConfigWarp = configDef