wai-middleware-delegate: WAI middleware that delegates handling of requests.

[ bsd3, library, web ] [ Propose Tags ]

WAI middleware to intercept requests that match a predicate and respond to them using other WAI Applications or proxied hosts. [WAI] http://hackage.haskell.org/package/wai


[Skip to Readme]
Versions [faq] 0.1.0.0, 0.1.1.0
Change log ChangeLog.md
Dependencies async (>=2.2.1 && <2.3), base (>=4.10 && <5), blaze-builder (>=0.4.1.0 && <0.5), bytestring (>=0.10.8.2 && <0.11), case-insensitive (>=1.2.0.11 && <1.3), conduit (>=1.3.0.3 && <1.4), conduit-extra (>=1.3.0 && <1.4), data-default (>=0.7.1.1 && <0.8), http-client (>=0.5.13.1 && <0.6), http-conduit (>=2.3.2 && <2.4), http-types (==0.12.1.*), streaming-commons (>=0.2.1.0 && <0.2.2), text (>=1.2.3.0 && <1.3), wai (==3.2.*), wai-conduit (>=3.0.0.4 && <3.1) [details]
License BSD-3-Clause
Author Tim Emiola
Maintainer tim.emiola@gmail.com
Category Web
Home page https://github.com/adetokunbo/wai-middleware-delegate
Bug tracker https://github.com/adetokunbo/wai-middleware-delegate/issues
Source repo head: git clone https://github.com/adetokunbo/wai-middleware-delegate.git
Uploaded by adetokunbo at Mon Aug 6 07:26:33 UTC 2018
Distributions NixOS:0.1.1.0
Downloads 193 total (18 in the last 30 days)
Rating 2.0 (votes: 1) [estimated by rule of succession]
Your Rating
  • λ
  • λ
  • λ
Status Hackage Matrix CI
Docs available [build log]
Last success reported on 2018-08-06 [all 1 reports]

Modules

[Index] [Quick Jump]

Downloads

Maintainer's Corner

For package maintainers and hackage trustees


Readme for wai-middleware-delegate-0.1.1.0

[back to package description]

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