4r-feed: add 4RUM_BASE_URL env var
parent
a02bf265ae
commit
d9559b582a
|
@ -5,6 +5,7 @@ import Relude.Extra.Tuple (fmapToSnd)
|
|||
|
||||
import Api.V1.Types
|
||||
import Data.Cache (newCache)
|
||||
import Data.List (isSuffixOf)
|
||||
import Feed.V1.Core (App)
|
||||
import Feed.V1.Section (feedSectionCached)
|
||||
import Feed.V1.Spec (FeedApi, feedApi)
|
||||
|
@ -36,13 +37,16 @@ mkServer = do
|
|||
Just (secRaw, Left e) -> fail $ "Failed to parse " <> cacheVarName <> "=" <> secRaw <> ": " <> toString e
|
||||
cache <- newCache $ Just TimeSpec{nsec = 0, sec}
|
||||
|
||||
baseUrl <- lookupEnv "4RUM_BASE_URL" >>= maybe (pure (BaseUrl Http "4rum.i2p" 80 "")) parseBaseUrl
|
||||
clientEnv <- do
|
||||
manager' <-
|
||||
liftIO $
|
||||
Http.newManager $
|
||||
Http.defaultManagerSettings
|
||||
& (Http.managerSetProxy $ Http.proxyEnvironmentNamed "I2P_HTTP_PROXY" $ Just defProxy)
|
||||
pure $ mkClientEnv manager' (BaseUrl Http "4rum.i2p" 80 "")
|
||||
& if ".i2p" `isSuffixOf` baseUrl.baseUrlHost
|
||||
then Http.managerSetProxy $ Http.proxyEnvironmentNamed "I2P_HTTP_PROXY" $ Just defProxy
|
||||
else id
|
||||
pure $ mkClientEnv manager' baseUrl
|
||||
|
||||
let interpreter :: App a -> Handler a
|
||||
interpreter =
|
||||
|
|
Loading…
Reference in New Issue