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 Details

    • reverseProxy

      static HttpProxy reverseProxy(HttpClient client)
      Create a new HttpProxy instance.
      Parameters:
      client - the HttpClient 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 new HttpProxy instance.
      Parameters:
      client - the HttpClient 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 the SocketAddress of the origin.
      Parameters:
      address - the SocketAddress 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 server
      host - the host name of the origin server
      Returns:
      a reference to this, so the API can be used fluently
    • origin

      HttpProxy origin(OriginRequestProvider provider)
      Set a provider that creates the request to the origin server based on ProxyContext.
      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 - the ProxyInterceptor 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 - the ProxyInterceptor to add
      supportsWebSocketUpgrade - 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 outbound HttpServerRequest.
      Specified by:
      handle in interface Handler<HttpServerRequest>
      Parameters:
      request - the outbound HttpServerRequest