Skip to content

Generate binding from io.vertx.httproxy.ProxyInterceptor interface ? #713

@lucaspouzac

Description

@lucaspouzac

Is it possible to generate the following interface from the io.vertx.httpproxy.ProxyInterceptor interface?
Currently, it is a class that is generated and it is not easy to use ? Or another idea ?

package io.vertx.mutiny.httpproxy;

import io.vertx.codegen.annotations.VertxGen;
import io.smallrye.mutiny.Uni;

/**
 * A {@link HttpProxy} interceptor.
 */
@io.smallrye.mutiny.vertx.MutinyGen(io.vertx.httpproxy.ProxyInterceptor.class)
public interface ProxyInterceptor {

  /**
   * Handle the proxy request at the stage of this interceptor.
   *
   * @param context the proxy context
   * @return when the request has actually been sent to the origin
   */
  default Uni<io.vertx.mutiny.httpproxy.ProxyResponse> handleProxyRequest(io.vertx.mutiny.httpproxy.ProxyContext context) {
    return context.sendRequest();
  }

  /**
   * Handle the proxy response at the stage of this interceptor.
   *
   * @param context the proxy context
   * @return when the response has actually been sent to the user-agent
   */
  default Uni<Void> handleProxyResponse(io.vertx.mutiny.httpproxy.ProxyContext context) {
    return context.sendResponse();
  }
}

Example of expected use.

public class TestInterceptor implements io.vertx.mutiny.httpproxy.ProxyInterceptor {

  public Uni<io.vertx.mutiny.httpproxy.ProxyResponse> handleProxyRequest(io.vertx.mutiny.httpproxy.ProxyContext context) {
    System.out.println("handleProxyRequest");
    return context.sendRequest();
  }

  public Uni<Void> handleProxyResponse(io.vertx.mutiny.httpproxy.ProxyContext context) {
    System.out.println("handleProxyResponse");
    return context.sendResponse();
  }

}

io.vertx.mutiny.core.Vertx vertx = ...;
io.vertx.mutiny.httpproxy.HttpProxy httpProxy = io.vertx.mutiny.httpproxy.HttpProxy.reverseProxy(vertx.createHttpClient());
httpProxy.addInterceptor(new TestInterceptor());

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions