ngx-export-tools-extra 1.2.12.1 → 1.2.12.2
raw patch · 9 files changed
+86/−74 lines, 9 filesdep ~bytestringPVP: major bump suggested
API removals or changes: PVP suggests a major version bump
Dependency ranges changed: bytestring
API changes (from Hackage documentation)
- NgxExport.Tools.EDE: renderEDETemplate :: ByteString -> ByteString -> IO ByteString
+ NgxExport.Tools.EDE: renderEDETemplate :: LazyByteString -> ByteString -> IO LazyByteString
- NgxExport.Tools.EDE: renderEDETemplateFromFreeValue :: ByteString -> IO ByteString
+ NgxExport.Tools.EDE: renderEDETemplateFromFreeValue :: ByteString -> IO LazyByteString
- NgxExport.Tools.EDE: renderEDETemplateWith :: (ByteString -> Maybe Value) -> HashMap Id Term -> ByteString -> ByteString -> IO ByteString
+ NgxExport.Tools.EDE: renderEDETemplateWith :: (LazyByteString -> Maybe Value) -> HashMap Id Term -> LazyByteString -> ByteString -> IO LazyByteString
- NgxExport.Tools.PCRE: gsubRegex :: ByteString -> IO ByteString
+ NgxExport.Tools.PCRE: gsubRegex :: ByteString -> IO LazyByteString
- NgxExport.Tools.PCRE: gsubRegexWith :: SubPasteF -> ByteString -> IO ByteString
+ NgxExport.Tools.PCRE: gsubRegexWith :: SubPasteF -> ByteString -> IO LazyByteString
- NgxExport.Tools.PCRE: matchRegex :: ByteString -> IO ByteString
+ NgxExport.Tools.PCRE: matchRegex :: ByteString -> IO LazyByteString
- NgxExport.Tools.PCRE: subRegex :: ByteString -> IO ByteString
+ NgxExport.Tools.PCRE: subRegex :: ByteString -> IO LazyByteString
- NgxExport.Tools.PCRE: subRegexWith :: SubPasteF -> ByteString -> IO ByteString
+ NgxExport.Tools.PCRE: subRegexWith :: SubPasteF -> ByteString -> IO LazyByteString
- NgxExport.Tools.Prometheus: scale1000 :: ByteString -> ByteString
+ NgxExport.Tools.Prometheus: scale1000 :: ByteString -> LazyByteString
- NgxExport.Tools.Subrequest: contentFromFullResponse :: HashSet HeaderName -> Bool -> (ByteString -> ByteString -> ByteString) -> ByteString -> ContentHandlerResult
+ NgxExport.Tools.Subrequest: contentFromFullResponse :: HashSet HeaderName -> Bool -> (LazyByteString -> ByteString -> LazyByteString) -> ByteString -> ContentHandlerResult
- NgxExport.Tools.Subrequest: extractBodyFromFullResponse :: ByteString -> ByteString
+ NgxExport.Tools.Subrequest: extractBodyFromFullResponse :: ByteString -> LazyByteString
- NgxExport.Tools.Subrequest: extractExceptionFromFullResponse :: ByteString -> ByteString
+ NgxExport.Tools.Subrequest: extractExceptionFromFullResponse :: ByteString -> LazyByteString
- NgxExport.Tools.Subrequest: extractHeaderFromFullResponse :: ByteString -> ByteString
+ NgxExport.Tools.Subrequest: extractHeaderFromFullResponse :: ByteString -> LazyByteString
- NgxExport.Tools.Subrequest: extractStatusFromFullResponse :: ByteString -> ByteString
+ NgxExport.Tools.Subrequest: extractStatusFromFullResponse :: ByteString -> LazyByteString
- NgxExport.Tools.Subrequest: makeBridgedSubrequest :: ByteString -> IO ByteString
+ NgxExport.Tools.Subrequest: makeBridgedSubrequest :: ByteString -> IO LazyByteString
- NgxExport.Tools.Subrequest: makeBridgedSubrequestFull :: ByteString -> IO ByteString
+ NgxExport.Tools.Subrequest: makeBridgedSubrequestFull :: ByteString -> IO LazyByteString
- NgxExport.Tools.Subrequest: makeBridgedSubrequestFullWithRead :: ByteString -> IO ByteString
+ NgxExport.Tools.Subrequest: makeBridgedSubrequestFullWithRead :: ByteString -> IO LazyByteString
- NgxExport.Tools.Subrequest: makeBridgedSubrequestWithRead :: ByteString -> IO ByteString
+ NgxExport.Tools.Subrequest: makeBridgedSubrequestWithRead :: ByteString -> IO LazyByteString
- NgxExport.Tools.Subrequest: makeSubrequest :: ByteString -> IO ByteString
+ NgxExport.Tools.Subrequest: makeSubrequest :: ByteString -> IO LazyByteString
- NgxExport.Tools.Subrequest: makeSubrequestFull :: ByteString -> IO ByteString
+ NgxExport.Tools.Subrequest: makeSubrequestFull :: ByteString -> IO LazyByteString
- NgxExport.Tools.Subrequest: makeSubrequestFullWithRead :: ByteString -> IO ByteString
+ NgxExport.Tools.Subrequest: makeSubrequestFullWithRead :: ByteString -> IO LazyByteString
- NgxExport.Tools.Subrequest: makeSubrequestWithRead :: ByteString -> IO ByteString
+ NgxExport.Tools.Subrequest: makeSubrequestWithRead :: ByteString -> IO LazyByteString
Files
- Changelog.md +4/−0
- NgxExport/Tools/Aggregate.hs +9/−8
- NgxExport/Tools/EDE.hs +11/−9
- NgxExport/Tools/PCRE.hs +12/−10
- NgxExport/Tools/Prometheus.hs +7/−7
- NgxExport/Tools/Resolve.hs +5/−4
- NgxExport/Tools/ServiceHookAdaptor.hs +6/−5
- NgxExport/Tools/Subrequest.hs +30/−29
- ngx-export-tools-extra.cabal +2/−2
Changelog.md view
@@ -1,3 +1,7 @@+### 1.2.12.2++- Use type synonym *LazyByteString* from *bytestring ≥ 0.11.2.0*.+ ### 1.2.12.1 - Group Template Haskell declarations to fix Haddock out-of-scope errors.
NgxExport/Tools/Aggregate.hs view
@@ -47,9 +47,9 @@ import Network.HTTP.Client import Foreign.C.Types import qualified Data.ByteString as B-import qualified Data.ByteString.Char8 as C8 import Data.ByteString (ByteString)-import qualified Data.ByteString.Lazy as L+import qualified Data.ByteString.Char8 as C8+import Data.ByteString.Lazy (LazyByteString) import Data.Map.Strict (Map) import qualified Data.Map.Strict as M import Data.IORef@@ -107,7 +107,7 @@ -- import NgxExport.Tools.Aggregate -- -- import Data.ByteString (ByteString)--- import qualified Data.ByteString.Lazy.Char8 as C8L+-- import Data.ByteString.Lazy (LazyByteString) -- import Data.Aeson -- import Data.Maybe -- import Data.IORef@@ -125,7 +125,7 @@ -- stats = unsafePerformIO $ newIORef $ Stats 0 0 0 -- {-\# NOINLINE stats \#-} ----- updateStats :: ByteString -> IO C8L.ByteString+-- updateStats :: ByteString -> IO LazyByteString -- __/updateStats/__ s = voidHandler $ do -- let cbs = 'NgxExport.Tools.Read.readFromByteString' \@Int s -- modifyIORef\' stats $ \\(Stats bs rs _) ->@@ -135,7 +135,7 @@ -- in Stats nbs nrs nmbs -- 'NgxExport.ngxExportIOYY' \'updateStats ----- reportStats :: Int -> Bool -> IO C8L.ByteString+-- reportStats :: Int -> Bool -> IO LazyByteString -- __/reportStats/__ = 'deferredService' $ \\port -> voidHandler $ do -- s <- readIORef stats -- 'reportAggregate' port (Just s) \"__/stats/__\"@@ -344,7 +344,7 @@ ) receiveAggregate :: FromJSON a =>- Aggregate a -> L.ByteString -> ByteString -> IO L.ByteString+ Aggregate a -> LazyByteString -> ByteString -> IO LazyByteString receiveAggregate a v sint = do let !s = decode' v !int = toNominalDiffTime $ readDef (Min 5) $ C8.unpack sint@@ -485,14 +485,15 @@ #ifdef SNAP_AGGREGATE_SERVER ,sigD uName [t|ByteString|] ,funD uName [clause [] (normalB [|C8.pack f|]) []]- ,sigD fName [t|AggregateServerConf -> Bool -> IO L.ByteString|]+ ,sigD fName [t|AggregateServerConf -> Bool -> IO LazyByteString|] ,funD fName [clause [] (normalB [|$(varE nameF) $(storage) $(varE uName)|]) [] ] #endif- ,sigD recvName [t|L.ByteString -> ByteString -> IO L.ByteString|]+ ,sigD recvName+ [t|LazyByteString -> ByteString -> IO LazyByteString|] ,funD recvName [clause [] (normalB [|$(varE nameRecv) $(storage)|])
NgxExport/Tools/EDE.hs view
@@ -45,6 +45,7 @@ import Data.ByteString (ByteString) import qualified Data.ByteString.Char8 as C8 import qualified Data.ByteString.Lazy as L+import Data.ByteString.Lazy (LazyByteString) import qualified Data.ByteString.Lazy.Char8 as C8L import Data.ByteString.Base64.URL #if MIN_VERSION_base64(1,0,0)@@ -86,9 +87,10 @@ -- -- import Data.ByteString (ByteString) -- import qualified Data.ByteString.Lazy as L+-- import Data.ByteString.Lazy (LazyByteString) -- import qualified Network.HTTP.Types.URI as URI ----- urlDecode :: ByteString -> L.ByteString+-- urlDecode :: ByteString -> LazyByteString -- urlDecode = L.fromStrict . URI.urlDecode False -- -- 'ngxExportYY' \'urlDecode@@ -260,11 +262,11 @@ -- | Renders an EDE template from a JSON object. -- -- This is the core function of the /renderEDETemplate/ handler. Accepts a JSON--- object written in a 'L.ByteString' and a key to find a compiled EDE template--- declared by the /compileEDETemplates/ handler.-renderEDETemplate :: L.ByteString -- ^ JSON object+-- object written in a 'Data.ByteString.Lazy.ByteString' and a key to find a+-- compiled EDE template declared by the /compileEDETemplates/ handler.+renderEDETemplate :: LazyByteString -- ^ JSON object -> ByteString -- ^ Key to find the EDE template- -> IO L.ByteString+ -> IO LazyByteString renderEDETemplate = renderEDETemplateWith decode extraEDEFilters -- | Renders an EDE template with custom decoding function and filters.@@ -272,11 +274,11 @@ -- Choice of the decoding function makes EDE available for templating from any -- configuration language that maps to the Aeson's 'Value'. renderEDETemplateWith- :: (L.ByteString -> Maybe Value) -- ^ Decoding function+ :: (LazyByteString -> Maybe Value) -- ^ Decoding function -> HashMap Id Term -- ^ Collection of extra filters- -> L.ByteString -- ^ JSON object+ -> LazyByteString -- ^ JSON object -> ByteString -- ^ Key to find the EDE template- -> IO L.ByteString+ -> IO LazyByteString renderEDETemplateWith fdec flt v k = do tpls <- readIORef templates case HM.lookup k tpls of@@ -307,7 +309,7 @@ -- as /key|$hs_json/. renderEDETemplateFromFreeValue :: ByteString -- ^ Key to find the EDE template | JSON object- -> IO L.ByteString+ -> IO LazyByteString renderEDETemplateFromFreeValue = uncurry (flip renderEDETemplate) . second (L.fromStrict . C8.tail) . C8.break (== '|')
NgxExport/Tools/PCRE.hs view
@@ -15,6 +15,7 @@ -- ----------------------------------------------------------------------------- + module NgxExport.Tools.PCRE ( -- * Matching against regular expressions -- $matchingPCRE@@ -37,6 +38,7 @@ import Data.ByteString (ByteString) import qualified Data.ByteString.Char8 as C8 import qualified Data.ByteString.Lazy as L+import Data.ByteString.Lazy (LazyByteString) import Data.List import qualified Data.List.NonEmpty as NE import Data.Maybe@@ -169,7 +171,7 @@ type RegexF = Regex -> ByteString -> IO ByteString -rtRegex :: RegexF -> ByteString -> IO L.ByteString+rtRegex :: RegexF -> ByteString -> IO LazyByteString rtRegex f = fmap L.fromStrict . uncurry doRtRegex . second C8.tail . C8.break (== '|') where doRtRegex k v = do@@ -196,7 +198,7 @@ -- This is the core function of the /matchRegex/ handler. matchRegex :: ByteString -- ^ Key to find the regex, and the value- -> IO L.ByteString+ -> IO LazyByteString matchRegex = rtRegex doMatchRegex -- $substitutionPCRE@@ -220,11 +222,11 @@ -- import NgxExport -- import NgxExport.Tools.PCRE ----- import Data.ByteString (ByteString) -- import qualified Data.ByteString as B--- import qualified Data.ByteString.Lazy as L+-- import Data.ByteString (ByteString)+-- import Data.ByteString.Lazy (LazyByteString) ----- gsubSwapAround :: ByteString -> IO L.ByteString+-- gsubSwapAround :: ByteString -> IO LazyByteString -- __/gsubSwapAround/__ = 'gsubRegexWith' $ const $ \\case -- a : d : b : _ -> B.concat [b, d, a] -- \_ -> B.empty@@ -313,7 +315,7 @@ -- This is the core function of the /subRegex/ handler. subRegex :: ByteString -- ^ Keys to find the regex and the sub, and the value- -> IO L.ByteString+ -> IO LazyByteString subRegex = rtRegex $ doSubRegex sub Nothing -- | Pastes /functional/ substitutions using a named regex and a function.@@ -322,7 +324,7 @@ subRegexWith :: SubPasteF -- ^ Function to paste substitutions -> ByteString -- ^ Keys to find the regex and the sub, and the value- -> IO L.ByteString+ -> IO LazyByteString subRegexWith = rtRegex . doSubRegex sub . Just -- | Pastes a named /plain/ substitution using a named regex.@@ -333,7 +335,7 @@ -- This is the core function of the /gsubRegex/ handler. gsubRegex :: ByteString -- ^ Keys to find the regex and the sub, and the value- -> IO L.ByteString+ -> IO LazyByteString gsubRegex = rtRegex $ doSubRegex gsub Nothing -- | Pastes /functional/ substitutions using a named regex and a function.@@ -343,7 +345,7 @@ gsubRegexWith :: SubPasteF -- ^ Function to paste substitutions -> ByteString -- ^ Keys to find the regex and the sub, and the value- -> IO L.ByteString+ -> IO LazyByteString gsubRegexWith = rtRegex . doSubRegex gsub . Just @@ -354,7 +356,7 @@ ngxExportSimpleServiceTyped 'declareRegexes ''InputRegexes restartPromptly -compileRegexes :: ByteString -> IO L.ByteString+compileRegexes :: ByteString -> IO LazyByteString compileRegexes = voidHandler' $ do !inputRegexes <- fromJust <$> readIORef storage_InputRegexes_declareRegexes let !compiledRegexes =
NgxExport/Tools/Prometheus.hs view
@@ -43,7 +43,7 @@ import qualified Data.HashSet as HS import Data.ByteString (ByteString) import qualified Data.ByteString.Char8 as C8-import qualified Data.ByteString.Lazy as L+import Data.ByteString.Lazy (LazyByteString) import qualified Data.ByteString.Lazy.Char8 as C8L import Data.IORef import Data.Text (Text)@@ -529,7 +529,7 @@ T.breakOn "@" k in T.concat [b, e, a] -showPrometheusMetrics :: PrometheusMetrics -> L.ByteString+showPrometheusMetrics :: PrometheusMetrics -> LazyByteString showPrometheusMetrics = TL.encodeUtf8 . M.foldlWithKey (\a k (h, ms) -> let k' = TL.fromStrict k@@ -590,7 +590,7 @@ ,n' ) -toPrometheusMetrics :: ByteString -> IO L.ByteString+toPrometheusMetrics :: ByteString -> IO LazyByteString toPrometheusMetrics v = do let cs = fromJust $ readFromByteStringAsJSON @AllMetrics v pc <- readIORef conf@@ -622,7 +622,7 @@ -- on conversion failure which results in returning an empty string. scale1000 :: ByteString -- ^ Floating point value- -> L.ByteString+ -> LazyByteString scale1000 v = let v' = fromJust $ readFromByteString @Double v in C8L.pack $ show $ scale 1000 v' @@ -868,7 +868,7 @@ extractValues = filter ((&&) <$> not . C8.null <*> isDigit . C8.head) . C8.splitWith ((&&) <$> not . isDigit <*> (/= '.')) -statusLayout :: ByteString -> L.ByteString+statusLayout :: ByteString -> LazyByteString statusLayout = C8L.pack . intercalate "," . map show . statuses where statuses s = runST $ do a <- newArray bs 0 :: ST s (STUArray s Int Int)@@ -888,12 +888,12 @@ cumulativeValue' :: (Num a, Read a) => ByteString -> a cumulativeValue' = foldr ((+) . (read . C8.unpack)) 0 . extractValues -cumulativeValue :: ByteString -> L.ByteString+cumulativeValue :: ByteString -> LazyByteString cumulativeValue = C8L.pack . show . cumulativeValue' @Int ngxExportYY 'cumulativeValue -cumulativeFPValue :: ByteString -> L.ByteString+cumulativeFPValue :: ByteString -> LazyByteString cumulativeFPValue = C8L.pack . show . cumulativeValue' @Double ngxExportYY 'cumulativeFPValue
NgxExport/Tools/Resolve.hs view
@@ -17,6 +17,7 @@ -- ----------------------------------------------------------------------------- + module NgxExport.Tools.Resolve ( -- * Dynamic upstreams in Nginx -- $dynamicUpstreams@@ -50,7 +51,7 @@ import Network.HTTP.Client.BrReadWithTimeout import Data.ByteString (ByteString) import qualified Data.ByteString.Char8 as C8-import qualified Data.ByteString.Lazy as L+import Data.ByteString.Lazy (LazyByteString) import Data.Map.Strict (Map) import qualified Data.Map.Strict as M import qualified Data.HashMap.Strict as HM@@ -412,11 +413,11 @@ httpManager = unsafePerformIO newTlsManager {-# NOINLINE httpManager #-} -getResponse :: Text -> (Request -> IO (Response L.ByteString)) ->- IO L.ByteString+getResponse :: Text -> (Request -> IO (Response LazyByteString)) ->+ IO LazyByteString getResponse url = fmap responseBody . (parseUrlThrow (T.unpack url) >>=) -getUrl :: Text -> IO L.ByteString+getUrl :: Text -> IO LazyByteString getUrl url = getResponse url $ flip httpLbsBrReadWithTimeout httpManager minimumTTL :: TTL -> [TTL] -> TTL
NgxExport/Tools/ServiceHookAdaptor.hs view
@@ -47,9 +47,10 @@ -- import NgxExport -- import NgxExport.Tools.ServiceHookAdaptor () ----- import Data.ByteString (ByteString) -- import qualified Data.ByteString as B+-- import Data.ByteString (ByteString) -- import qualified Data.ByteString.Lazy as L+-- import Data.ByteString.Lazy (LazyByteString) -- import Data.IORef -- import Control.Monad -- import Control.Exception@@ -65,7 +66,7 @@ -- secretWord = unsafePerformIO $ newIORef "" -- {-\# NOINLINE secretWord \#-} ----- testSecretWord :: ByteString -> IO L.ByteString+-- testSecretWord :: ByteString -> IO LazyByteString -- __/testSecretWord/__ v = do -- s <- readIORef secretWord -- when (B.null s) $ throwIO SecretWordUnset@@ -74,7 +75,7 @@ -- else \"\" -- 'NgxExport.ngxExportIOYY' 'testSecretWord ----- changeSecretWord :: ByteString -> IO L.ByteString+-- changeSecretWord :: ByteString -> IO LazyByteString -- __/changeSecretWord/__ s = do -- writeIORef secretWord s -- return \"The secret word was changed\"@@ -196,7 +197,7 @@ -- -- ==== File /test_tools_extra_servicehookadaptor.hs/: reset the secret word -- @--- resetSecretWord :: ByteString -> IO L.ByteString+-- resetSecretWord :: ByteString -> IO LazyByteString -- __/resetSecretWord/__ = const $ do -- writeIORef secretWord \"\" -- return \"The secret word was reset\"@@ -234,7 +235,7 @@ -- properly log the reset case. -- -- @--- changeSecretWord :: ByteString -> IO L.ByteString+-- changeSecretWord :: ByteString -> IO LazyByteString -- __/changeSecretWord/__ s = do -- writeIORef secretWord s -- return $ \"The secret word was \" \`L.append\` if B.null s
NgxExport/Tools/Subrequest.hs view
@@ -65,6 +65,7 @@ import qualified Data.ByteString as B import qualified Data.ByteString.Char8 as C8 import qualified Data.ByteString.Lazy as L+import Data.ByteString.Lazy (LazyByteString) import qualified Data.ByteString.Lazy.Char8 as C8L import Data.IORef import qualified Data.Text.Encoding as T@@ -104,7 +105,7 @@ -- import NgxExport.Tools.Subrequest -- -- import Data.ByteString (ByteString)--- import qualified Data.ByteString.Lazy as L+-- import Data.ByteString.Lazy (LazyByteString) -- -- makeRequest :: ByteString -> 'NgxExportService' -- __/makeRequest/__ = const . 'makeSubrequest'@@ -252,7 +253,7 @@ data SubrequestConf = SubrequestConf { srMethod :: ByteString , srUri :: String- , srBody :: L.ByteString+ , srBody :: LazyByteString , srHeaders :: RequestHeaders , srResponseTimeout :: ResponseTimeout , srManager :: ConnectionManager@@ -305,19 +306,20 @@ setTimeout _ = undefined subrequest :: (String -> IO Request) ->- (Response L.ByteString -> L.ByteString) -> SubrequestConf ->- IO L.ByteString+ (Response LazyByteString -> LazyByteString) -> SubrequestConf ->+ IO LazyByteString subrequest parseRequestF buildResponseF sub@SubrequestConf {..} = do man <- getManager sub req <- parseRequestF srUri buildResponseF <$> httpLbsBrReadWithTimeout (makeRequest sub req) man -subrequestBody :: SubrequestConf -> IO L.ByteString+subrequestBody :: SubrequestConf -> IO LazyByteString subrequestBody = subrequest parseUrlThrow responseBody -type FullResponse = (Int, [(ByteString, ByteString)], L.ByteString, ByteString)+type FullResponse =+ (Int, [(ByteString, ByteString)], LazyByteString, ByteString) -handleFullResponse :: IO L.ByteString -> IO L.ByteString+handleFullResponse :: IO LazyByteString -> IO LazyByteString handleFullResponse = handle $ \e -> do let msg = C8.pack $ show e responseXXX = (, [], "", msg)@@ -336,14 +338,14 @@ _ -> response500 _ -> response500 -buildFullResponse :: Response L.ByteString -> L.ByteString+buildFullResponse :: Response LazyByteString -> LazyByteString buildFullResponse r = let status = statusCode $ responseStatus r headers = map (first original) $ responseHeaders r body = responseBody r in Binary.encode @FullResponse (status, headers, body, "") -subrequestFull :: SubrequestConf -> IO L.ByteString+subrequestFull :: SubrequestConf -> IO LazyByteString subrequestFull = handleFullResponse . subrequest parseRequest buildFullResponse httpManager :: Manager@@ -406,7 +408,7 @@ -- /haskell_var_empty_on_error/. makeSubrequest :: ByteString -- ^ Subrequest configuration- -> IO L.ByteString+ -> IO LazyByteString makeSubrequest = maybe (throwIO SubrequestParseError) subrequestBody . readFromByteStringAsJSON @SubrequestConf@@ -434,7 +436,7 @@ -- manager. makeSubrequestWithRead :: ByteString -- ^ Subrequest configuration- -> IO L.ByteString+ -> IO LazyByteString makeSubrequestWithRead = maybe (throwIO SubrequestParseError) subrequestBody . readFromByteString @SubrequestConf@@ -532,12 +534,11 @@ -- import NgxExport.Tools.Subrequest -- -- import Data.ByteString (ByteString)--- import qualified Data.ByteString.Lazy as L+-- import qualified Data.ByteString.Char8 as C8 -- -- import Network.HTTP.Client hiding (path) -- import qualified Network.Socket as S -- import qualified Network.Socket.ByteString as SB--- import qualified Data.ByteString.Char8 as C8 -- -- configureUdsManager :: ByteString -> 'NgxExportService' -- __/configureUdsManager/__ = 'ignitionService' $ \\path -> 'voidHandler' $ do@@ -756,7 +757,7 @@ -- /makeSubrequestFull/. makeSubrequestFull :: ByteString -- ^ Subrequest configuration- -> IO L.ByteString+ -> IO LazyByteString makeSubrequestFull = maybe (return $ Binary.encode @FullResponse@@ -773,7 +774,7 @@ -- /makeSubrequestFullWithRead/. makeSubrequestFullWithRead :: ByteString -- ^ Subrequest configuration- -> IO L.ByteString+ -> IO LazyByteString makeSubrequestFullWithRead = maybe (return $ Binary.encode @FullResponse@@ -787,7 +788,7 @@ -- /extractStatusFromFullResponse/. extractStatusFromFullResponse :: ByteString -- ^ Encoded HTTP response- -> L.ByteString+ -> LazyByteString extractStatusFromFullResponse = C8L.pack . show . (\(a, _, _, _) -> a) . Binary.decode @FullResponse . L.fromStrict @@ -803,7 +804,7 @@ -- found. extractHeaderFromFullResponse :: ByteString -- ^ Encoded HTTP response- -> L.ByteString+ -> LazyByteString extractHeaderFromFullResponse v = let (h, b) = mk *** C8.tail $ C8.break ('|' ==) v (_, hs, _, _) = Binary.decode @FullResponse $ L.fromStrict b@@ -816,7 +817,7 @@ -- /extractBodyFromFullResponse/. extractBodyFromFullResponse :: ByteString -- ^ Encoded HTTP response- -> L.ByteString+ -> LazyByteString extractBodyFromFullResponse = (\(_, _, a, _) -> a) . Binary.decode @FullResponse . L.fromStrict @@ -830,7 +831,7 @@ -- subrequest. Non-/2xx/ responses are not regarded as exceptions as well. extractExceptionFromFullResponse :: ByteString -- ^ Encoded HTTP response- -> L.ByteString+ -> LazyByteString extractExceptionFromFullResponse = L.fromStrict . (\(_, _, _, a) -> a) . Binary.decode @FullResponse . L.fromStrict @@ -948,7 +949,7 @@ contentFromFullResponse :: HashSet HeaderName -- ^ Set of not forwardable response headers -> Bool -- ^ Do not forward /X-Accel-.../ response headers- -> (L.ByteString -> ByteString -> L.ByteString)+ -> (LazyByteString -> ByteString -> LazyByteString) -- ^ Function to compose response body and exception -> ByteString -- ^ Encoded HTTP response -> ContentHandlerResult@@ -986,7 +987,7 @@ -- -- ==== File /test_tools_extra_subrequest.hs/: auxiliary read body handler -- @--- reqBody :: L.ByteString -> ByteString -> IO L.ByteString+-- reqBody :: LazyByteString -> ByteString -> IO LazyByteString -- reqBody = const . return -- -- 'ngxExportAsyncOnReqBody' \'reqBody@@ -1132,8 +1133,8 @@ req { requestBody = RequestBodyStreamChunked givesPopper } bridgedSubrequest :: (String -> IO Request) ->- (Response L.ByteString -> L.ByteString) -> BridgeConf ->- IO L.ByteString+ (Response LazyByteString -> LazyByteString) -> BridgeConf ->+ IO LazyByteString bridgedSubrequest parseRequestF buildResponseF BridgeConf {..} = do manIn <- getManager bridgeSource manOut <- getManager bridgeSink@@ -1155,10 +1156,10 @@ httpLbsBrReadWithTimeout (makeStreamingRequest givesPopper bridgeSink reqOut') manOut -bridgedSubrequestBody :: BridgeConf -> IO L.ByteString+bridgedSubrequestBody :: BridgeConf -> IO LazyByteString bridgedSubrequestBody = bridgedSubrequest parseUrlThrow responseBody -bridgedSubrequestFull :: BridgeConf -> IO L.ByteString+bridgedSubrequestFull :: BridgeConf -> IO LazyByteString bridgedSubrequestFull = handleFullResponse . bridgedSubrequest parseRequest buildFullResponse @@ -1197,7 +1198,7 @@ -- /haskell_var_empty_on_error/. makeBridgedSubrequest :: ByteString -- ^ Bridge configuration- -> IO L.ByteString+ -> IO LazyByteString makeBridgedSubrequest = maybe (throwIO BridgeParseError) bridgedSubrequestBody . readFromByteStringAsJSON @BridgeConf@@ -1239,7 +1240,7 @@ -- must be listed in this order. makeBridgedSubrequestWithRead :: ByteString -- ^ Bridge configuration- -> IO L.ByteString+ -> IO LazyByteString makeBridgedSubrequestWithRead = maybe (throwIO BridgeParseError) bridgedSubrequestBody . readFromByteString @BridgeConf@@ -1254,7 +1255,7 @@ -- /makeBridgedSubrequestFull/. makeBridgedSubrequestFull :: ByteString -- ^ Bridge configuration- -> IO L.ByteString+ -> IO LazyByteString makeBridgedSubrequestFull = maybe (return $ Binary.encode @FullResponse@@ -1271,7 +1272,7 @@ -- /makeBridgedSubrequestFullWithRead/. makeBridgedSubrequestFullWithRead :: ByteString -- ^ Bridge configuration- -> IO L.ByteString+ -> IO LazyByteString makeBridgedSubrequestFullWithRead = maybe (return $ Binary.encode @FullResponse
ngx-export-tools-extra.cabal view
@@ -1,5 +1,5 @@ name: ngx-export-tools-extra-version: 1.2.12.1+version: 1.2.12.2 synopsis: More extra tools for Nginx Haskell module description: More extra tools for <https://github.com/lyokha/nginx-haskell-module Nginx Haskell module>.@@ -37,7 +37,7 @@ default-language: Haskell2010 build-depends: base >= 4.8 && < 5 , template-haskell >= 2.11.0.0- , bytestring >= 0.10.0.0+ , bytestring >= 0.11.2.0 , base64 >= 0.3.0.0 , ngx-export , ngx-export-tools >= 1.2.6