|
|
|
@ -90,7 +90,7 @@ public class WebClient {
|
|
|
|
|
conf.respHandler.accept(hresp);
|
|
|
|
|
}
|
|
|
|
|
} catch (Throwable e) {
|
|
|
|
|
throw Assert.runtimeException(e);
|
|
|
|
|
conf.errorHandler.accept(Assert.rootCause(e));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
@ -111,7 +111,7 @@ public class WebClient {
|
|
|
|
|
conf.respHandler.accept(hresp);
|
|
|
|
|
}
|
|
|
|
|
} catch (Throwable e) {
|
|
|
|
|
throw Assert.runtimeException(e);
|
|
|
|
|
conf.errorHandler.accept(Assert.rootCause(e));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -129,6 +129,9 @@ public class WebClient {
|
|
|
|
|
System.out.println("status: " + hresp.statusCode());
|
|
|
|
|
System.out.println(hresp.body());
|
|
|
|
|
};
|
|
|
|
|
private Consumer<Throwable> errorHandler = t -> {
|
|
|
|
|
System.out.println(t.getMessage());
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
public Config header(String key, String value) {
|
|
|
|
|
if (headers == null)
|
|
|
|
@ -169,6 +172,11 @@ public class WebClient {
|
|
|
|
|
return this;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public Config onError(Consumer<Throwable> handler) {
|
|
|
|
|
errorHandler = handler;
|
|
|
|
|
return this;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
HttpRequest get() {
|
|
|
|
|
String queryString = getParams();
|
|
|
|
|
if (!queryString.isEmpty())
|
|
|
|
|