Working dotenv configuration
This commit is contained in:
17
src/Core/Configuration.hs
Normal file
17
src/Core/Configuration.hs
Normal file
@ -0,0 +1,17 @@
|
||||
module Core.Configuration where
|
||||
|
||||
import Configuration.Dotenv
|
||||
import System.Environment (getEnv, lookupEnv)
|
||||
|
||||
main :: IO ()
|
||||
main = do
|
||||
envFile <- lookupEnv "NOENVFILE"
|
||||
case envFile of
|
||||
Nothing -> loadFile defaultConfig
|
||||
_ -> putStrLn "Not using dotenv"
|
||||
|
||||
appPort :: IO String
|
||||
appPort = getEnv "APPLICATIONPORT"
|
||||
|
||||
appTitle :: IO String
|
||||
appTitle = getEnv "BLOGTITLE"
|
@ -1,6 +1,7 @@
|
||||
module Core.HTTP where
|
||||
|
||||
import qualified Core.Handlers as Handle
|
||||
import qualified Core.Configuration as Conf
|
||||
import qualified Core.Handlers as Handle
|
||||
|
||||
import Network.Wai.Middleware.RequestLogger (logStdoutDev)
|
||||
import Network.Wai.Handler.Warp (Port, run)
|
||||
@ -8,7 +9,8 @@ import Web.Twain
|
||||
|
||||
main :: IO ()
|
||||
main = do
|
||||
run appPort $
|
||||
port <- Conf.appPort
|
||||
run (read port :: Int) $
|
||||
foldr ($) (notFound Handle.missing) app
|
||||
|
||||
-- Combine our Preprocessor Middlewares and Routes to create an App
|
||||
@ -25,7 +27,3 @@ routes =
|
||||
[ get "/" Handle.index
|
||||
, get "/echo/:testParam" Handle.testRoute
|
||||
]
|
||||
|
||||
-- This will be replaced with getEnv located in Configuration
|
||||
appPort :: Port
|
||||
appPort = 3000
|
||||
|
@ -1,6 +1,7 @@
|
||||
module Main where
|
||||
|
||||
import qualified Core.HTTP as Core
|
||||
import qualified Core.HTTP as Core
|
||||
import qualified Core.Configuration as Conf
|
||||
|
||||
main :: IO ()
|
||||
main = Core.main
|
||||
main = Conf.main >>= (\_ -> Core.main)
|
||||
|
Reference in New Issue
Block a user