Giter Site home page Giter Site logo

connectionapi's Introduction

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

connectionapi's People

Stargazers

Levin avatar

Watchers

Asedem avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.