reworked constants into configurable settings

This commit is contained in:
Lucy Cifferello
2020-03-12 17:26:27 -06:00
parent 924f5df8e1
commit 74d3c0c1b8
10 changed files with 97 additions and 92 deletions

View File

@@ -23,8 +23,9 @@ import Yesod.Core
import Foundation
import Lib.Registry
import Lib.Semver
import System.FilePath ((<.>))
import System.FilePath ((<.>), (</>))
import System.Posix.Files (fileSize, getFileStatus)
import Settings
pureLog :: Show a => a -> Handler a
pureLog = liftA2 (*>) ($logInfo . show) pure
@@ -38,13 +39,22 @@ instance Show FileExtension where
show (FileExtension f (Just e)) = f <.> e
getAppsManifestR :: Handler TypedContent
getAppsManifestR = respondSource typePlain $ CB.sourceFile appManifestPath .| awaitForever sendChunkBS
getAppsManifestR = do
AppSettings{..} <- appSettings <$> getYesod
let appResourceDir = resourcesDir </> "apps" </> "apps.yaml"
respondSource typePlain $ CB.sourceFile appResourceDir .| awaitForever sendChunkBS
getSysR :: Extension "" -> Handler TypedContent
getSysR = getApp sysResourceDir
getSysR e = do
AppSettings{..} <- appSettings <$> getYesod
let sysResourceDir = resourcesDir </> "sys"
getApp sysResourceDir e
getAppR :: Extension "s9pk" -> Handler TypedContent
getAppR = getApp appResourceDir
getAppR e = do
AppSettings{..} <- appSettings <$> getYesod
let appResourceDir = resourcesDir </> "apps" </> "apps.yaml"
getApp appResourceDir e
getApp :: KnownSymbol a => FilePath -> Extension a -> Handler TypedContent
getApp rootDir ext = do