Safe Haskell | None |
---|---|
Language | Haskell2010 |
- data ServiceProxy
- serviceProxy :: (Show e, Typeable e) => Manager -> ProxyAdapter e -> ActionState -> Server ServiceProxy
- reverseProxyHandler :: (Show e, Typeable e) => ProxyAdapter e -> ActionState -> Request -> IO WaiProxyResponse
- data ProxyAdapter e = ProxyAdapter {
- renderHeader :: RenderHeaderFun
- renderUser :: UserId -> User -> Action e () SBS
- renderError :: ActionError e -> IO ServantErr
- defaultProxyAdapter :: ProxyAdapter Void
- defaultRenderUser :: UserId -> User -> Action e () SBS
- prepareReq :: ProxyAdapter e -> RequestHeaders -> ByteString -> Request -> Request
- data RqMod = RqMod ProxyUri RequestHeaders
- getRqMod :: ProxyAdapter e -> Request -> Action e () RqMod
- findTargetForServiceId :: ServiceId -> ThentosConfig -> Action e () (ServiceId, ProxyUri)
- findDefaultServiceIdAndTarget :: ThentosConfig -> Action e () (ServiceId, ProxyUri)
- createCustomHeaders :: ProxyAdapter e -> Maybe ThentosSessionToken -> ServiceId -> Action e () RequestHeaders
- err500onExc :: SomeException -> Application
Documentation
data ServiceProxy
HasServer * ServiceProxy | |
type Foreign ServiceProxy = Req | |
type ServerT * ServiceProxy m = Application |
serviceProxy :: (Show e, Typeable e) => Manager -> ProxyAdapter e -> ActionState -> Server ServiceProxy
reverseProxyHandler :: (Show e, Typeable e) => ProxyAdapter e -> ActionState -> Request -> IO WaiProxyResponse
Proxy or respond based on request headers.
data ProxyAdapter e
Allows adapting a proxy for a specific use case.
ProxyAdapter | |
|
defaultProxyAdapter :: ProxyAdapter Void
defaultRenderUser :: UserId -> User -> Action e () SBS
Render the user by showing their name.
prepareReq :: ProxyAdapter e -> RequestHeaders -> ByteString -> Request -> Request
data RqMod
Request modifier that contains all information that is needed to alter and forward an incoming request.
getRqMod :: ProxyAdapter e -> Request -> Action e () RqMod
Create request modifier with custom headers to add to it and the target URL of the proxied app to forward it to.
If the request contains a X-Thentos-Service
header, we find the proxied app based on
this header -- an error is thrown if the "proxies" section of the config doesn't match.
Otherwise, the default proxied app from the "proxy" section of the config is used --
an error is thrown if that section is missing.
If the request contains a X-Thentos-Session
header, we validate the session and set the
X-Thentos-User
and X-Thentos-Groups
headers accordingly. Otherwise the request is
forwarded as an anonymous request (no user logged in).
The first parameter allows adapting a proxy for a specific use case.
To get the default behavior, use defaultProxyAdapter
.
findTargetForServiceId :: ServiceId -> ThentosConfig -> Action e () (ServiceId, ProxyUri)
Look up the target URL for requests based on the given service ID. This requires a "proxies" section in the config. An error is thrown if this section is missing or doesn't contain a match. For convenience, both service ID and target URL are returned.
findDefaultServiceIdAndTarget :: ThentosConfig -> Action e () (ServiceId, ProxyUri)
Look up the service ID and target URL in the "proxy" section of the config. An error is thrown if that section is missing.
createCustomHeaders :: ProxyAdapter e -> Maybe ThentosSessionToken -> ServiceId -> Action e () RequestHeaders
Create headers identifying the user and their groups. Returns an empty list in case of an anonymous request.
err500onExc :: SomeException -> Application
Throw an internal server error if the proxied app is unreachable.