Have yesod load correct config files when developing

This commit is contained in:
Gregor Kleen 2017-10-04 14:12:27 +02:00
parent 2d2b1a2ed3
commit e2e6ab3798

View File

@ -125,14 +125,14 @@ warpSettings foundation =
-- | For yesod devel, return the Warp settings and WAI Application. -- | For yesod devel, return the Warp settings and WAI Application.
getApplicationDev :: IO (Settings, Application) getApplicationDev :: IO (Settings, Application)
getApplicationDev = do getApplicationDev = do
settings <- getAppSettings settings <- getAppDevSettings
foundation <- makeFoundation settings foundation <- makeFoundation settings
wsettings <- getDevSettings $ warpSettings foundation wsettings <- getDevSettings $ warpSettings foundation
app <- makeApplication foundation app <- makeApplication foundation
return (wsettings, app) return (wsettings, app)
getAppSettings :: IO AppSettings getAppDevSettings :: IO AppSettings
getAppSettings = loadYamlSettings [configSettingsYml] [] useEnv getAppDevSettings = loadYamlSettings [".dbsettings.yml", "config/test-settings.yml", configSettingsYml] [configSettingsYmlValue] useEnv
-- | main function for use by yesod devel -- | main function for use by yesod devel
develMain :: IO () develMain :: IO ()
@ -164,7 +164,7 @@ appMain = do
-------------------------------------------------------------- --------------------------------------------------------------
getApplicationRepl :: IO (Int, App, Application) getApplicationRepl :: IO (Int, App, Application)
getApplicationRepl = do getApplicationRepl = do
settings <- getAppSettings settings <- getAppDevSettings
foundation <- makeFoundation settings foundation <- makeFoundation settings
wsettings <- getDevSettings $ warpSettings foundation wsettings <- getDevSettings $ warpSettings foundation
app1 <- makeApplication foundation app1 <- makeApplication foundation
@ -180,7 +180,7 @@ shutdownApp _ = return ()
-- | Run a handler -- | Run a handler
handler :: Handler a -> IO a handler :: Handler a -> IO a
handler h = getAppSettings >>= makeFoundation >>= flip unsafeHandler h handler h = getAppDevSettings >>= makeFoundation >>= flip unsafeHandler h
-- | Run DB queries -- | Run DB queries
db :: ReaderT SqlBackend (HandlerT App IO) a -> IO a db :: ReaderT SqlBackend (HandlerT App IO) a -> IO a