I would like to set the approot value to the value from the Approot env variable in a yesod project. How do i do this? This is my main function:
appRootStatic <- (getEnv "APPROOT") warpEnv $ Piggies pool manager appRootStatic
The issue is that in approot function I have no way to get to the Piggies constructor as Approot is not an instance of MonadHandler?
data Piggies = Piggies { connPool :: ConnectionPool, httpManager:: Manager, staticURL :: String }
approot = do
master <- getYesod
ApprootMaster master (staticURL master)
I had tried ApprootStatic before i tried the ApprootMaster data constructor.
The compiler complains: "No instance for Monad Approot arising from a do statement. So my question is how to stick the value of the APPROOT variable into approot?
Thanks,
What you need to do is:
APPROOT
environment variable.approot
in terms of ApprootMaster
.main
function, read the APPROOT
environment variable and set the field in your foundation datatype.The scaffolding does all of this for you automatically.