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

Latest on Hackage:

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.

BSD-3-Clause 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.


{-# 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 (..),

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


Revision history for wai-middleware-delegate – 2018-07-28

  • Initial version. – 2018-08-06

  • Add configuration for the number of redirects
comments powered byDisqus