Skip to content

Asedem/ConnectionAPI

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

32 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Made with Java


Made with Java

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

Installation

Maven

Repository

<repositories>
    <repository>
        <id>jitpack.io</id>
        <url>https://jitpack.io</url>
    </repository>
</repositories>

Dependency

<dependency>
    <groupId>com.github.Asedem</groupId>
    <artifactId>ConnectionAPI</artifactId>
    <version>5ffcfef027</version>
</dependency>

Gradle

Repository

repositories {
    maven { url 'https://jitpack.io' }
}

Dependency

dependencies {
    implementation 'com.github.Asedem:ConnectionAPI:5ffcfef027'
}

Rest

Http Methods

The most important Http Methods are Supported:

GET, PUT, HEAD, POST, TRACE, PATCH, DELETE, CONNECT, OPTIONS

General Request

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) -> ...);

Get JSON as a predefined Java Object

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();
            }
        });

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Languages