diff options
Diffstat (limited to 'Settings.hs')
-rw-r--r-- | Settings.hs | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/Settings.hs b/Settings.hs index 63cbd15..d0e16ea 100644 --- a/Settings.hs +++ b/Settings.hs | |||
@@ -19,6 +19,8 @@ import Yesod.Default.Config2 (applyEnvValue, configSettingsYml) | |||
19 | import Yesod.Default.Util (WidgetFileSettings, widgetFileNoReload, | 19 | import Yesod.Default.Util (WidgetFileSettings, widgetFileNoReload, |
20 | widgetFileReload) | 20 | widgetFileReload) |
21 | 21 | ||
22 | import Thermoprint.Client (BaseUrl(..), Scheme(..), InvalidBaseUrlException, parseBaseUrl) | ||
23 | |||
22 | #ifdef DEVELOPMENT | 24 | #ifdef DEVELOPMENT |
23 | #define DEV_BOOL True | 25 | #define DEV_BOOL True |
24 | #else | 26 | #else |
@@ -47,11 +49,14 @@ data AppSettings = AppSettings | |||
47 | -- ^ Should all log messages be displayed? | 49 | -- ^ Should all log messages be displayed? |
48 | , appReloadTemplates :: Bool | 50 | , appReloadTemplates :: Bool |
49 | -- ^ Use the reload version of templates | 51 | -- ^ Use the reload version of templates |
52 | |||
53 | , appThermoprintBase :: BaseUrl | ||
50 | } | 54 | } |
51 | 55 | ||
52 | instance FromJSON AppSettings where | 56 | instance FromJSON AppSettings where |
53 | parseJSON = withObject "AppSettings" $ \o -> do | 57 | parseJSON = withObject "AppSettings" $ \o -> do |
54 | let defaultDev = DEV_BOOL | 58 | let defaultDev = DEV_BOOL |
59 | parseUrl' = either (fail . show) return . parseBaseUrl | ||
55 | appStaticDir <- o .: "static-dir" | 60 | appStaticDir <- o .: "static-dir" |
56 | appDatabaseConf <- o .: "database" | 61 | appDatabaseConf <- o .: "database" |
57 | appHost <- fromString <$> o .: "host" | 62 | appHost <- fromString <$> o .: "host" |
@@ -62,6 +67,8 @@ instance FromJSON AppSettings where | |||
62 | appShouldLogAll <- o .:? "should-log-all" .!= defaultDev | 67 | appShouldLogAll <- o .:? "should-log-all" .!= defaultDev |
63 | appReloadTemplates <- o .:? "reload-templates" .!= defaultDev | 68 | appReloadTemplates <- o .:? "reload-templates" .!= defaultDev |
64 | 69 | ||
70 | appThermoprintBase <- parseUrl' =<< o .: "thermoprint-url" | ||
71 | |||
65 | return AppSettings {..} | 72 | return AppSettings {..} |
66 | 73 | ||
67 | -- | Settings for 'widgetFile', such as which template languages to support and | 74 | -- | Settings for 'widgetFile', such as which template languages to support and |