Package io.vertx.httpproxy
Interface HttpProxy
-
- All Superinterfaces:
Handler<HttpServerRequest>
public interface HttpProxy extends Handler<HttpServerRequest>
Handles the HTTP reverse proxy logic between the user agent and the origin.- Author:
- Julien Viet
-
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description default HttpProxy
addInterceptor(ProxyInterceptor interceptor)
Add an interceptor to the interceptor chain.HttpProxy
addInterceptor(ProxyInterceptor interceptor, boolean supportsWebSocketUpgrade)
Add an interceptor to the interceptor chain.void
handle(HttpServerRequest request)
Handle the outboundHttpServerRequest
.default HttpProxy
origin(int port, String host)
Set the host name and port number of the origin.default HttpProxy
origin(SocketAddress address)
Set theSocketAddress
of the origin.HttpProxy
originRequestProvider(java.util.function.BiFunction<HttpServerRequest,HttpClient,Future<HttpClientRequest>> provider)
Set a provider that creates the request to the origin server based the incoming HTTP request.default HttpProxy
originSelector(java.util.function.Function<HttpServerRequest,Future<SocketAddress>> selector)
Set a selector that resolves the origin address based on the incoming HTTP request.static HttpProxy
reverseProxy(HttpClient client)
Create a newHttpProxy
instance.static HttpProxy
reverseProxy(ProxyOptions options, HttpClient client)
Create a newHttpProxy
instance.
-
-
-
Method Detail
-
reverseProxy
static HttpProxy reverseProxy(HttpClient client)
Create a newHttpProxy
instance.- Parameters:
client
- theHttpClient
that forwards outbound requests to the origin.- Returns:
- a reference to this, so the API can be used fluently.
-
reverseProxy
static HttpProxy reverseProxy(ProxyOptions options, HttpClient client)
Create a newHttpProxy
instance.- Parameters:
client
- theHttpClient
that forwards outbound requests to the origin.- Returns:
- a reference to this, so the API can be used fluently.
-
origin
default HttpProxy origin(SocketAddress address)
Set theSocketAddress
of the origin.- Parameters:
address
- theSocketAddress
of the origin- Returns:
- a reference to this, so the API can be used fluently
-
origin
default HttpProxy origin(int port, String host)
Set the host name and port number of the origin.- Parameters:
port
- the port number of the origin serverhost
- the host name of the origin server- Returns:
- a reference to this, so the API can be used fluently
-
originSelector
default HttpProxy originSelector(java.util.function.Function<HttpServerRequest,Future<SocketAddress>> selector)
Set a selector that resolves the origin address based on the incoming HTTP request.- Parameters:
selector
- the selector- Returns:
- a reference to this, so the API can be used fluently
-
originRequestProvider
HttpProxy originRequestProvider(java.util.function.BiFunction<HttpServerRequest,HttpClient,Future<HttpClientRequest>> provider)
Set a provider that creates the request to the origin server based the incoming HTTP request. Setting a provider overrides any origin selector previously set.- Parameters:
provider
- the provider- Returns:
- a reference to this, so the API can be used fluently
-
addInterceptor
default HttpProxy addInterceptor(ProxyInterceptor interceptor)
Add an interceptor to the interceptor chain.Interceptors are invoked in order of configuration. When added with this method, it is considered the interceptor doesn't support WebSocket upgrades.
- Parameters:
interceptor
- theProxyInterceptor
to add- Returns:
- a reference to this, so the API can be used fluently
-
addInterceptor
HttpProxy addInterceptor(ProxyInterceptor interceptor, boolean supportsWebSocketUpgrade)
Add an interceptor to the interceptor chain.Interceptors are invoked in order of configuration.
- Parameters:
interceptor
- theProxyInterceptor
to addsupportsWebSocketUpgrade
- whether the interceptor supports WebSocket upgrades- Returns:
- a reference to this, so the API can be used fluently
-
handle
void handle(HttpServerRequest request)
Handle the outboundHttpServerRequest
.- Specified by:
handle
in interfaceHandler<HttpServerRequest>
- Parameters:
request
- the outboundHttpServerRequest
-
-