graphql-engine/server/src-lib/Network/HTTP/Client/CreateManager.hs
Puru Gupta c437a42f6d server: rename SchemaCacheRef to AppStateRef and add AppContext to it
PR-URL: https://github.com/hasura/graphql-engine-mono/pull/8159
Co-authored-by: Naveen Naidu <30195193+Naveenaidu@users.noreply.github.com>
Co-authored-by: Anon Ray <616387+ecthiender@users.noreply.github.com>
GitOrigin-RevId: a57f6dc8b3e992d86490e5c51508827f00151dfe
2023-03-17 10:30:38 +00:00

21 lines
876 B
Haskell

module Network.HTTP.Client.CreateManager
( mkHttpManager,
)
where
import Hasura.Prelude
import Hasura.RQL.Types.Network (TlsAllow)
import Network.HTTP.Client qualified as HTTP
import Network.HTTP.Client.Blocklisting (Blocklist, block)
import Network.HTTP.Client.DynamicTlsPermissions qualified as HTTP
import Network.HTTP.Client.Restricted qualified as Restricted
-- | This mkHttpManager function takes a mechanism for finding the current allowlist,
-- | Thus allowing it to be coupled from any ref type such as AppStateRef.
-- | A mechanism to block IPs (both IPv4 and IPv6) has also been added to it.
mkHttpManager :: IO [TlsAllow] -> Blocklist -> IO HTTP.Manager
mkHttpManager currentAllow blocklist = do
tlsSettings <- HTTP.dynamicTlsSettings currentAllow
HTTP.newManager $
Restricted.mkRestrictedManagerSettings (block blocklist) Nothing (Just tlsSettings)