Package org.microproxy
Interface FailureResponder
- Functional Interface:
- This is a functional interface and can therefore be used as the assignment target for a lambda expression or method reference.
Makes the proxy's own answer when a request fails (
ProxyFailure), e.g. to send branded
error pages or JSON instead of the default plain-text body. Install it with HttpProxyServerBootstrap.withFailureResponder(org.microproxy.FailureResponder).
Filters are asked first (HttpFilters.proxyToServerFailure(org.microproxy.ProxyFailure)); the responder is only
consulted when none of them answers. Whatever it returns is framed by the proxy as usual: a
Content-Length matching the body, the connection's keep-alive state, and no body for
HEAD. The response then passes HttpFilters.proxyToClientResponse(org.microproxy.http.HttpObject) like the
proxy's other responses.
The responder runs on the client connection's virtual thread and may be called concurrently for different connections. If it throws, the failure is logged and the default answer is sent.
-
Method Summary
Modifier and TypeMethodDescriptionrespond(HttpRequest request, ProxyFailure failure) Returns the response forfailure, ornullfor the proxy's default.
-
Method Details
-
respond
Returns the response forfailure, ornullfor the proxy's default.- Parameters:
request- the request as the proxy was about to forward it (after filters and the proxy's own header changes); avoid echoing its parts into an HTML body unescapedfailure- the proxy failure to answer- Returns:
- the response to send, or
nullfor the proxy default
-