Skip to content

Commit

Permalink
Merge pull request #521 from hiddenalpha/SDCISA-12877-ImplAnotherHttp…
Browse files Browse the repository at this point in the history
…ClientMethod

Implement another HttpClient method
  • Loading branch information
hiddenalpha authored Oct 4, 2023
2 parents dd39752 + 0870603 commit 16c28a5
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,27 @@
import io.vertx.core.Future;
import io.vertx.core.Handler;
import io.vertx.core.MultiMap;
import io.vertx.core.Vertx;
import io.vertx.core.http.*;

import java.util.List;
import java.util.function.Function;

import static io.vertx.core.Future.succeededFuture;

/**
* Base class with empty method implementations.
*
* @author https://github.com/lbovet [Laurent Bovet]
*/
public abstract class AbstractHttpClient implements HttpClient {

private final Vertx vertx;

public AbstractHttpClient(Vertx vertx) {
this.vertx = vertx;
}

protected abstract HttpClientRequest doRequest(HttpMethod method, String uri);

public HttpClientRequest options(String uri) {
Expand Down Expand Up @@ -71,7 +80,7 @@ public Future<HttpClientRequest> request(RequestOptions requestOptions) {

@Override
public void request(HttpMethod httpMethod, int i, String s, String s1, Handler<AsyncResult<HttpClientRequest>> handler) {
Future.succeededFuture(doRequest(httpMethod, s1)).onComplete(handler);
vertx.runOnContext(v -> succeededFuture(doRequest(httpMethod, s1)).onComplete(handler));
}

@Override
Expand All @@ -90,7 +99,7 @@ public Future<HttpClientRequest> request(HttpMethod httpMethod, String s, String

@Override
public void request(HttpMethod method, String requestURI, Handler<AsyncResult<HttpClientRequest>> handler) {
throw new UnsupportedOperationException();
vertx.runOnContext(v -> succeededFuture(doRequest(method, requestURI)).onComplete(handler));
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ public class LocalHttpClient extends AbstractHttpClient {
private Vertx vertx;

public LocalHttpClient(Vertx vertx) {
super(vertx);
this.vertx = vertx;
}

Expand Down

0 comments on commit 16c28a5

Please sign in to comment.