happstack-server-7.1.7.1: Web related tools and services.

Safe Haskell | None

Happstack.Server.Proxy

Description

Support for creating a proxy or reverse-proxy server

Synopsis

- proxyServe :: (MonadIO m, WebMonad Response m, ServerMonad m, MonadPlus m, FilterMonad Response m) => [String] -> m Response
- proxyServe' :: (MonadIO m, FilterMonad Response m, WebMonad Response m) => Request -> m Response
- rproxyServe :: (ServerMonad m, WebMonad Response m, FilterMonad Response m, MonadIO m) => String -> [(String, String)] -> m Response
- unproxify :: Request -> Request
- unrproxify :: String -> [(String, String)] -> Request -> Request

# Documentation

proxyServe :: (MonadIO m, WebMonad Response m, ServerMonad m, MonadPlus m, FilterMonad Response m) => [String] -> m Response

`proxyServe` is for creating a part that acts as a proxy. The sole argument `[`String`]` is a list of allowed domains for proxying. This matches the domain part of the request and the wildcard * can be used. E.g.

- "*" to match anything.
- "*.example.com" to match anything under example.com
- "example.com" to match just example.com

TODO: annoyingly enough, this method eventually calls `escape`, so any headers you set won't be used, and the computation immediately ends.

proxyServe' :: (MonadIO m, FilterMonad Response m, WebMonad Response m) => Request -> m Response

Take a proxy `Request` and create a `Response`. Your basic proxy building block. See `unproxify`.

TODO: this would be more useful if it didn't call `escape` (e.g. it let you modify the response afterwards, or set additional headers)

rproxyServe

Arguments

:: (ServerMonad m, WebMonad Response m, FilterMonad Response m, MonadIO m) |
=> String | defaultHost
-> [(String, String)] | map to look up hostname mappings. For the reverse proxy
-> m Response | the result is a `ServerPartT` that will reverse proxy for you.

This is a reverse proxy implementation. See `unrproxify`.

TODO: this would be more useful if it didn't call `escape`, just like `proxyServe'`.

unproxify :: Request -> Request

unrproxify :: String -> [(String, String)] -> Request -> Request