http-reverse-proxy 0.1.0.7 → 0.1.1
raw patch · 2 files changed
+25/−4 lines, 2 filesdep +data-defaultPVP ok
version bump matches the API change (PVP)
Dependencies added: data-default
API changes (from Hackage documentation)
+ Network.HTTP.ReverseProxy: data WaiProxySettings
+ Network.HTTP.ReverseProxy: def :: Default a => a
+ Network.HTTP.ReverseProxy: instance Default WaiProxySettings
+ Network.HTTP.ReverseProxy: waiProxyToSettings :: (Request -> ResourceT IO (Either Response ProxyDest)) -> WaiProxySettings -> Manager -> Request -> ResourceT IO Response
+ Network.HTTP.ReverseProxy: wpsOnExc :: WaiProxySettings -> SomeException -> Application
+ Network.HTTP.ReverseProxy: wpsTimeout :: WaiProxySettings -> Maybe Int
Files
- Network/HTTP/ReverseProxy.hs +23/−3
- http-reverse-proxy.cabal +2/−1
Network/HTTP/ReverseProxy.hs view
@@ -7,6 +7,12 @@ -- * WAI + http-conduit , waiProxyTo , defaultOnExc+ , waiProxyToSettings+ -- ** Settings+ , WaiProxySettings+ , def+ , wpsOnExc+ , wpsTimeout -- * WAI to Raw , waiToRaw ) where@@ -30,6 +36,7 @@ import Data.Conduit.Binary (sourceFileRange) import qualified Data.IORef as I import Network.Socket (PortNumber (PortNum), SockAddr (SockAddrInet))+import Data.Default (Default (def)) -- | Host\/port combination to which we want to proxy. data ProxyDest = ProxyDest@@ -110,7 +117,20 @@ -- simple 502 error page, use 'defaultOnExc'. -> HC.Manager -- ^ connection manager to utilize -> WAI.Application-waiProxyTo getDest onError manager req = do+waiProxyTo getDest onError = waiProxyToSettings getDest def { wpsOnExc = onError }++data WaiProxySettings = WaiProxySettings+ { wpsOnExc :: SomeException -> WAI.Application+ , wpsTimeout :: Maybe Int+ }++instance Default WaiProxySettings where+ def = WaiProxySettings+ { wpsOnExc = defaultOnExc+ , wpsTimeout = Nothing+ }++waiProxyToSettings getDest wps manager req = do edest <- getDest req case edest of Left response -> return response@@ -125,11 +145,11 @@ , HC.requestBody = HC.RequestBodySourceChunked $ mapOutput fromByteString $ WAI.requestBody req , HC.redirectCount = 0 , HC.checkStatus = \_ _ -> Nothing- , HC.responseTimeout = Nothing+ , HC.responseTimeout = wpsTimeout wps } ex <- try $ HC.http req' manager case ex of- Left e -> onError e req+ Left e -> wpsOnExc wps e req Right res -> do (src, _) <- unwrapResumable $ HC.responseBody res return $ WAI.ResponseSource
http-reverse-proxy.cabal view
@@ -1,5 +1,5 @@ name: http-reverse-proxy-version: 0.1.0.7+version: 0.1.1 synopsis: Reverse proxy HTTP requests, either over raw sockets or with WAI description: Provides a simple means of reverse-proxying HTTP requests. The raw approach uses the same technique as leveraged by keter, whereas the WAI approach performs full request/response parsing via WAI and http-conduit. homepage: https://github.com/fpco/http-reverse-proxy@@ -29,6 +29,7 @@ , network , conduit >= 0.5 , warp >= 1.3.4+ , data-default test-suite test type: exitcode-stdio-1.0