ngx-export-tools-extra 1.2.3 → 1.2.4
raw patch · 5 files changed
+28/−24 lines, 5 filesdep +http-client-tlsPVP ok
version bump matches the API change (PVP)
Dependencies added: http-client-tls
API changes (from Hackage documentation)
Files
- Changelog.md +4/−0
- NgxExport/Tools/PCRE.hs +4/−2
- NgxExport/Tools/Prometheus.hs +1/−1
- NgxExport/Tools/Subrequest.hs +17/−20
- ngx-export-tools-extra.cabal +2/−1
Changelog.md view
@@ -1,3 +1,7 @@+### 1.2.4++- Added support for *https* connections in module *NgxExport.Tools.Subrequest*.+ ### 1.2.3 - In module *NgxExport.Tools.EDE*, custom EDE filters are now passed into
NgxExport/Tools/PCRE.hs view
@@ -283,7 +283,7 @@ -- -- ==== File /test_tools_extra_pcre.hs/ -- @--- {-\# LANGUAGE TemplateHaskell \#-}+-- {-\# LANGUAGE TemplateHaskell, LambdaCase \#-} -- -- module TestToolsExtraPCRE where --@@ -295,7 +295,9 @@ -- import qualified Data.ByteString.Lazy as L -- -- gsubSwapAround :: ByteString -> IO L.ByteString--- __/gsubSwapAround/__ = 'gsubRegexWith' $ \\_ (a : d : b : _) -> B.concat [b, d, a]+-- __/gsubSwapAround/__ = 'gsubRegexWith' $ const $ \\case +-- a : d : b : _ -> B.concat [b, d, a]+-- \_ -> B.empty -- -- 'ngxExportIOYY' \'gsubSwapAround -- @
NgxExport/Tools/Prometheus.hs view
@@ -579,7 +579,7 @@ ] ,n )- _ -> a+ _ -> a else let n' = n + v in (TL.concat [t, k ,"_bucket{le=\"", TL.fromStrict l, "\""
NgxExport/Tools/Subrequest.hs view
@@ -4,7 +4,7 @@ ----------------------------------------------------------------------------- -- | -- Module : NgxExport.Tools.Subrequest--- Copyright : (c) Alexey Radkov 2020-2022+-- Copyright : (c) Alexey Radkov 2020-2023 -- License : BSD-style -- -- Maintainer : alexey.radkov@gmail.com@@ -53,6 +53,7 @@ import Network.HTTP.Client hiding (ResponseTimeout) import qualified Network.HTTP.Client (HttpExceptionContent (ResponseTimeout))+import Network.HTTP.Client.TLS (newTlsManager) import Network.HTTP.Client.BrReadWithTimeout import Network.HTTP.Types import qualified Network.Socket as S@@ -129,7 +130,7 @@ -- } -- -- haskell_run_service __/simpleService_makeRequest/__ $hs_service_httpbin--- \'{\"uri\": \"http:\/\/httpbin.org\"}\';+-- \'{\"uri\": \"https:\/\/httpbin.org\"}\'; -- -- haskell_var_empty_on_error $hs_subrequest; --@@ -255,10 +256,9 @@ srUseUDS <- fromMaybe False <$> o .:? "useUDS" return SubrequestConf {..} -data BridgeConf =- BridgeConf { bridgeSource :: SubrequestConf- , bridgeSink :: SubrequestConf- } deriving Read+data BridgeConf = BridgeConf { bridgeSource :: SubrequestConf+ , bridgeSink :: SubrequestConf+ } deriving Read instance FromJSON BridgeConf where parseJSON = withObject "BridgeConf" $ \o -> do@@ -290,10 +290,7 @@ (Response L.ByteString -> L.ByteString) -> SubrequestConf -> IO L.ByteString subrequest parseRequestF buildResponseF sub@SubrequestConf {..} = do- man <- if srUseUDS- then fromMaybe (throw UDSNotConfiguredError) <$>- readIORef httpUDSManager- else return httpManager+ man <- getManager sub req <- parseRequestF srUri buildResponseF <$> httpLbsBrReadWithTimeout (makeRequest sub req) man @@ -332,13 +329,19 @@ subrequestFull = handleFullResponse . subrequest parseRequest buildFullResponse httpManager :: Manager-httpManager = unsafePerformIO $ newManager defaultManagerSettings+httpManager = unsafePerformIO newTlsManager {-# NOINLINE httpManager #-} httpUDSManager :: IORef (Maybe Manager) httpUDSManager = unsafePerformIO $ newIORef Nothing {-# NOINLINE httpUDSManager #-} +getManager :: SubrequestConf -> IO Manager+getManager SubrequestConf {..}+ | srUseUDS =+ fromMaybe (throw UDSNotConfiguredError) <$> readIORef httpUDSManager+ | otherwise = return httpManager+ -- | Makes an HTTP request. -- -- This is the core function of the /makeSubrequest/ handler. From perspective@@ -478,7 +481,7 @@ { managerRawConnection = return $ openUDS udsPath } writeIORef httpUDSManager $ Just man return ""- where openUDS path _ _ _ = do+ where openUDS path _ _ _ = do s <- S.socket S.AF_UNIX S.Stream S.defaultProtocol S.connect s (S.SockAddrUnix path) makeConnection (SB.recv s 4096) (SB.sendAll s) (S.close s)@@ -1025,14 +1028,8 @@ (Response L.ByteString -> L.ByteString) -> BridgeConf -> IO L.ByteString bridgedSubrequest parseRequestF buildResponseF BridgeConf {..} = do- manIn <- if srUseUDS bridgeSource- then fromMaybe (throw UDSNotConfiguredError) <$>- readIORef httpUDSManager- else return httpManager- manOut <- if srUseUDS bridgeSink- then fromMaybe (throw UDSNotConfiguredError) <$>- readIORef httpUDSManager- else return httpManager+ manIn <- getManager bridgeSource+ manOut <- getManager bridgeSink -- BEWARE: a non-2xx response from the bridge source will throw -- StatusCodeException with this status which finally will be returned as -- the status code of the whole bridged subrequest
ngx-export-tools-extra.cabal view
@@ -1,5 +1,5 @@ name: ngx-export-tools-extra-version: 1.2.3+version: 1.2.4 synopsis: More extra tools for Nginx haskell module description: More extra tools for <https://github.com/lyokha/nginx-haskell-module Nginx haskell module>.@@ -43,6 +43,7 @@ , ngx-export-tools >= 1.0 , http-types >= 0.7.0 , http-client >= 0.5.3+ , http-client-tls >= 0.3.4 , http-client-brread-timeout , network >= 2.4.0.0 , async >= 2.0.1.0