A Modern HTTP Client API for GWT, Requestor offers all features needed for a current robust AJAX application. It is pleasant to use and fully configurable and extensible.
Requesting is now simple and nice.
requestor.req("http://httpbin.org/ip").get(String.class).done(new DoneCallback<String>() {
public void onDone(String result) {
Window.alert(result);
}
});
With Java 8 support, it will be really cool!
requestor.req("http://httpbin.org/ip").get(String.class).done(Window::alert);
The low-level RequestBuilder way would be...
/* Original GWT RequestBuilder approach */
RequestBuilder rb = new RequestBuilder(RequestBuilder.GET, "http://httpbin.org/ip");
rb.setCallback(new RequestCallback() {
@Override
public void onResponseReceived(Request request, Response response) {
String result = response.getText();
Window.alert(result);
}
@Override
public void onError(Request request, Throwable exception) {
// ...
}
});
try {
rb.send();
} catch (RequestException e) {
// ...
}
Make a request is a trivial task and now you can do it healthily. :)
Requesting will never be boring again!
Almost all features are working perfectly in all modern browsers, except:
0.2.0 (18 Feb 2015)
The minimal installation requires two dependencies, the core API and some implementation. The default implementation is requestor-gdeferred, which exposes GDeferred's Promise API.
<dependency>
<groupId>io.reinert.gdeferred</groupId>
<artifactId>gdeferred</artifactId>
<version>0.9.0</version>
</dependency>
<dependency>
<groupId>io.reinert.requestor.impl</groupId>
<artifactId>requestor-gdeferred</artifactId>
<version>0.2.0</version>
</dependency>
<dependency>
<groupId>io.reinert.requestor.core</groupId>
<artifactId>requestor-api</artifactId>
<version>0.2.0</version>
</dependency>
To make requestor available to your GWT project, import the implementation's module.
<inherits name="io.reinert.requestor.RequestorByGDeferred"/>
Read the Getting Started wiki page for more information.
If you want to use the latest snapshot, you need to add the sonatype snapshot repository to your POM.
<repositories>
...
<repository>
<id>oss-sonatype</id>
<url>https://oss.sonatype.org/content/repositories/snapshots/</url>
<snapshots>
<enabled>true</enabled>
</snapshots>
</repository>
...
</repositories>
Requestor is freely distributable under the Apache 2.0 License