Class ApiProxy

java.lang.Object
net.targetr.rc.util.ApiProxy

public class ApiProxy extends Object
Proxies HTTP requests to external APIs, injecting necessary API keys. Handles predefined API targets and requires valid keys in api-keys.properties.
  • Constructor Details

    • ApiProxy

      public ApiProxy(HttpRequest httpReq)
      Constructs a new ApiProxy for the given HTTP request.
      Parameters:
      httpReq - the incoming HTTP request to proxy
  • Method Details

    • generateResponse

      public HttpResponse generateResponse() throws Exception
      Generates a response by proxying the request to the target API. Injects the required API key based on the target endpoint.
      Returns:
      the HTTP response from the external API, or an error response if the target is unknown or the key is missing
      Throws:
      Exception - if an error occurs during proxying