Interface WebRequestGateway

All Superinterfaces:
HasLocalHandlers
All Known Implementing Classes:
DefaultWebRequestGateway

public interface WebRequestGateway extends HasLocalHandlers
Gateway for sending outbound web requests via Flux Capacitor’s proxy mechanism.

This gateway does not directly execute the request. Instead, it logs the request as a WebRequest message, which is then picked up by the Flux platform's proxy. The proxy only executes the request if the request URL is absolute (e.g., starts with http:// or https://).

Benefits of this approach include:

  • Traceability: All outbound web traffic is traceable through Flux message logs.
  • Centralization: Outgoing requests are routed via a centralized proxy, simplifying firewalling and monitoring.
  • Proxy-level enhancements: The proxy can apply retries, circuit breakers, filtering, and other behaviors.

This gateway also supports local request handlers, meaning that annotated methods (e.g., @HandleWebRequest) can respond to requests directly within the application if desired.

See Also:
  • Field Details

    • defaultSettings

      static final WebRequestSettings defaultSettings
      Default request settings used when none are specified explicitly.
  • Method Details

    • sendAndForget

      CompletableFuture<Void> sendAndForget(Guarantee guarantee, WebRequest... requests)
      Sends one or more web requests without waiting for a response.

      Use this for fire-and-forget scenarios (e.g., async webhook posts).

      Parameters:
      guarantee - indicates whether to wait until the request is sent or stored
      requests - the web requests to send
      Returns:
      a future that completes once the requests have been sent or stored
    • send

      Sends the given web request and returns a future that completes with the response.

      The request must have an absolute URL to be forwarded by the Flux proxy.

      Parameters:
      request - the web request to send
      Returns:
      a future completed with the WebResponse
    • sendAndWait

      default WebResponse sendAndWait(WebRequest request)
      Sends the given web request and waits for the response synchronously using default request settings.

      This method blocks the calling thread until the request is completed or times out.

      Parameters:
      request - the web request to send
      Returns:
      the received WebResponse
    • sendAndWait

      WebResponse sendAndWait(WebRequest request, WebRequestSettings settings)
      Sends the given web request and waits for the response synchronously using the specified request settings.

      This method blocks the calling thread until the request is completed or times out.

      Parameters:
      request - the web request to send
      settings - configuration settings for this request (e.g., timeouts, accepted encodings)
      Returns:
      the received WebResponse
    • close

      void close()
      Gracefully shuts down the gateway and releases any associated resources.