aboutsummaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorstuebinm2024-05-21 20:24:36 +0200
committerstuebinm2024-05-21 20:24:36 +0200
commit4fe7828e2364c5daeb70765ecfb1513b01bfb14e (patch)
tree48af094d78590c23c78b52c4caead23a351eddbe /lib
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?)
Diffstat (limited to 'lib')
-rw-r--r--lib/Config.hs9
1 files changed, 7 insertions, 2 deletions
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