wai-middleware-delegate

WAI middleware that delegates handling of requests. https://github.com/adetokunbo/wai-middleware-delegate

Latest on Hackage:0.1.1.0

This package is not currently in any snapshots. If you're interested in using it, we recommend adding it to Stackage Nightly. Doing so will make builds more reliable, and allow stackage.org to host generated Haddocks.

BSD3 licensed by Tim Emiola
Maintained by tim.emiola@gmail.com

wai-middleware-delegate CircleCI BSD3

wai-middleware-delegate is a WAI middleware that allows requests to be handled by a delegate application that proxies requests to another server.

Example

{-# LANGUAGE OverloadedStrings #-}

import           Data.Default                    (Default (..))
import           Network.HTTP.Client.TLS         (newTlsManager)
import           Network.HTTP.Types              (status500)
import           Network.Wai
import           Network.Wai.Handler.Warp (run)
import           Network.Wai.Middleware.Delegate (ProxySettings (..),
                                                  delegateToProxy)

sampleSettings :: ProxySettings
sampleSettings = def { proxyHost = "httpbin.org" }

-- | Create an application that proxies every request to httpbin.org
httpBinDelegate :: ProxySettings -> IO Application
httpBinDelegate s = do
  -- delegate everything!
  let takeItAll = const True
      dummyApp _ respond = respond $ responseLBS status500 [] "I should have been proxied"

  manager <- newTlsManager
  return $ delegateToProxy s manager (takeItAll) dummyApp

main :: IO ()
main = httpBinDelegate sampleSettings >>= run 3000

Changes

Revision history for wai-middleware-delegate

0.1.0.0 – 2018-07-28

  • Initial version.

0.1.1.0 – 2018-08-06

  • Add configuration for the number of redirects
comments powered byDisqus