-- Hoogle documentation, generated by Haddock
-- See Hoogle, http://www.haskell.org/hoogle/

-- | Reverse proxy HTTP requests, either over raw sockets or with WAI
--   
--   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.
@package http-reverse-proxy
@version 0.6.2.0

module Network.HTTP.ReverseProxy

-- | Host/port combination to which we want to proxy.
data ProxyDest
ProxyDest :: !ByteString -> !Int -> ProxyDest
[pdHost] :: ProxyDest -> !ByteString
[pdPort] :: ProxyDest -> !Int

-- | Set up a reverse proxy server, which will have a minimal overhead.
--   
--   This function uses raw sockets, parsing as little of the request as
--   possible. The workflow is:
--   
--   
--   
- Parse the first request headers.
--   
- Ask the supplied function to specify how to reverse proxy.
--   
- Open up a connection to the given host/port.
--   
- Pass all bytes across the wire unchanged.
--   
--   
--   If you need more control, such as modifying the request or response,
--   use waiProxyTo.
rawProxyTo :: MonadUnliftIO m => (RequestHeaders -> m (Either (AppData -> m ()) ProxyDest)) -> AppData -> m ()

-- | Set up a reverse tcp proxy server, which will have a minimal overhead.
--   
--   This function uses raw sockets, parsing as little of the request as
--   possible. The workflow is:
--   
--   
--   
- Open up a connection to the given host/port.
--   
- Pass all bytes across the wire unchanged.
--   
--   
--   If you need more control, such as modifying the request or response,
--   use waiProxyTo.
rawTcpProxyTo :: MonadIO m => ProxyDest -> AppData -> m ()

-- | Creates a WAI Application which will handle reverse proxies.
--   
--   Connections to the proxied server will be provided via http-conduit.
--   As such, all requests and responses will be fully processed in your
--   reverse proxy. This allows you much more control over the data sent
--   over the wire, but also incurs overhead. For a lower-overhead
--   approach, consider rawProxyTo.
--   
--   Most likely, the given application should be run with Warp, though in
--   theory other WAI handlers will work as well.
--   
--   Note: This function will use chunked request bodies for communicating
--   with the proxied server. Not all servers necessarily support chunked
--   request bodies, so please confirm that yours does (Warp, Snap, and
--   Happstack, for example, do).
waiProxyTo :: (Request -> IO WaiProxyResponse) -> (SomeException -> Application) -> Manager -> Application

-- | Sends a simple 502 bad gateway error message with the contents of the
--   exception.
defaultOnExc :: SomeException -> Application
waiProxyToSettings :: (Request -> IO WaiProxyResponse) -> WaiProxySettings -> Manager -> Application

-- | The different responses that could be generated by a
--   waiProxyTo lookup function.
data WaiProxyResponse

-- | Respond with the given WAI Response.
WPRResponse :: Response -> WaiProxyResponse

-- | Send to the given destination.
WPRProxyDest :: ProxyDest -> WaiProxyResponse

-- | Send to the given destination via HTTPS.
WPRProxyDestSecure :: ProxyDest -> WaiProxyResponse

-- | Send to the given destination, but use the given modified Request for
--   computing the reverse-proxied request. This can be useful for reverse
--   proxying to a different path than the one specified. By the user. The
--   path will be taken from rawPathInfo while the queryString from
--   rawQueryString of the request.
WPRModifiedRequest :: Request -> ProxyDest -> WaiProxyResponse

-- | Same as WPRModifiedRequest but send to the given destination via
--   HTTPS.
WPRModifiedRequestSecure :: Request -> ProxyDest -> WaiProxyResponse

-- | Respond with the given WAI Application.
WPRApplication :: Application -> WaiProxyResponse
data WaiProxySettings

-- | Default value for WaiProxySettings
defaultWaiProxySettings :: WaiProxySettings
wpsOnExc :: WaiProxySettings -> SomeException -> Application
wpsTimeout :: WaiProxySettings -> Maybe Int

-- | Set the X-Real-IP request header with the client's IP address.
--   
--   Default: SIHFromSocket
wpsSetIpHeader :: WaiProxySettings -> SetIpHeader

-- | Post-process the response body returned from the host. The API for
--   this function changed to include the extra Request parameter in
--   version 0.5.0.
wpsProcessBody :: WaiProxySettings -> Request -> Response () -> Maybe (ConduitT ByteString (Flush Builder) IO ())

-- | Determine if the request should be upgraded to a raw proxy connection,
--   as is needed for WebSockets. Requires WAI 2.1 or higher and a WAI
--   handler with raw response support (e.g., Warp) to work.
--   
--   Default: check if the upgrade header is websocket.
wpsUpgradeToRaw :: WaiProxySettings -> Request -> Bool

-- | Allow to override proxy settings for each request. If you supply this
--   field it will take precedence over getDest parameter in
--   waiProxyToSettings
--   
--   Default: have one global setting
wpsGetDest :: WaiProxySettings -> Maybe (Request -> IO (LocalWaiProxySettings, WaiProxyResponse))

-- | Function provided to log the Request that is constructed.
--   
--   Default: no op
wpsLogRequest :: WaiProxySettings -> Request -> IO ()

-- | Allow to override the response headers before the response is returned
--   upstream. Useful for example to override overly-strict
--   'Content-Security-Policy' when the source is known to be trustworthy.
--   
--   Default: no op
wpsModifyResponseHeaders :: WaiProxySettings -> Request -> Response () -> ResponseHeaders -> ResponseHeaders

-- | How to set the X-Real-IP request header.
data SetIpHeader

-- | Do not set the header
SIHNone :: SetIpHeader

-- | Set it from the socket's address.
SIHFromSocket :: SetIpHeader

-- | Set it from either X-Real-IP or X-Forwarded-For, if present
SIHFromHeader :: SetIpHeader
data LocalWaiProxySettings

-- | Default value for LocalWaiProxySettings, same as def
--   but with a more explicit name.
defaultLocalWaiProxySettings :: LocalWaiProxySettings

-- | Allows to specify the maximum time allowed for the conection on per
--   request basis.
--   
--   Default: no timeouts
setLpsTimeBound :: Maybe Int -> LocalWaiProxySettings -> LocalWaiProxySettings
instance GHC.Classes.Eq Network.HTTP.ReverseProxy.ProxyDest
instance GHC.Internal.Generics.Generic Network.HTTP.ReverseProxy.ProxyDest
instance GHC.Classes.Ord Network.HTTP.ReverseProxy.ProxyDest
instance GHC.Internal.Read.Read Network.HTTP.ReverseProxy.ProxyDest
instance GHC.Internal.Show.Show Network.HTTP.ReverseProxy.ProxyDest
