ConnectionAPI is a library, where you can perform rest request or do a socket connection for example
It will get bigger over time, but slowly, because it is just a side project
<repositories>
<repository>
<id>jitpack.io</id>
<url>https://jitpack.io</url>
</repository>
</repositories><dependency>
<groupId>com.github.Asedem</groupId>
<artifactId>ConnectionAPI</artifactId>
<version>5ffcfef027</version>
</dependency>repositories {
maven { url 'https://jitpack.io' }
}dependencies {
implementation 'com.github.Asedem:ConnectionAPI:5ffcfef027'
}The most important Http Methods are Supported:
GET, PUT, HEAD, POST, TRACE, PATCH, DELETE, CONNECT, OPTIONS
Requesting a sync raw JSON
final JSONObject jsonObject = Rest.requestSync(new URL("<Your URL>"), HttpMethode.<Your Methode>)
.asRawValue();
...Requesting an async raw JSON
Rest.request(new URL("<Your URL>"), HttpMethode.<Your Methode>)
.whenComplete((restRequest, throwable) -> ...);Java Object example class
public record Data(
Integer id,
String name,
String email
) {
}Requesting the JSON as the Data object sync
final Data data = Rest.requestSync(new URL("<Your URL>"), HttpMethode.<Your Methode>)
.asJavaObject(Data.class)
.get();
...Requesting the JSON as the Data object async
Rest.request(new URL("<Your URL>"), HttpMethode.<Your Methode>)
.whenComplete((restRequest, throwable) -> {
try {
final Data data = restRequest.asJavaObject(Data.class).get();
...
} catch (JsonProcessingException exception) {
exception.printStackTrace();
}
});