<dependency> <groupId>hu.szit</groupId> <artifactId>resclient</artifactId> <version>1.3.2</version> </dependency>
Ha moduláris alkalmazást készítünk, a module-info.java fájlba:
module valami { requires hu.szit.resclient; opens com.example to hu.szit.resclient; }
GitHub weblap:
import hu.szit.ResClientAsync; public class UseResclient { public static void get() { String url = "https://jsonplaceholder.typicode.com/users"; ResClientAsync client = new ResClientAsync(); String res = client.get(url).join(); System.out.println(res); } public static void post() { String url = "https://jsonplaceholder.typicode.com/users"; ResClientAsync client = new ResClientAsync(); String body = "{\"name\":\"John\", \"age\":30, \"city\":\"New York\"}"; String res = client.post(url, body).join(); System.out.println(res); } public static void put() { String url = "https://jsonplaceholder.typicode.com/users/1"; ResClientAsync client = new ResClientAsync(); String body = "{\"name\":\"John\", \"age\":30, \"city\":\"New York\"}"; String res = client.put(url, body).join(); System.out.println(res); } public static void delete() { String url = "https://jsonplaceholder.typicode.com/users/1"; ResClientAsync client = new ResClientAsync(); String res = client.delete(url).join(); System.out.println(res); } }
import hu.szit.ResClient; public class UseResclient { public static void get() { String url = "https://jsonplaceholder.typicode.com/users"; ResClient client = new ResClient(); String res = client.get(url); System.out.println(res); } public static void post() { String url = "https://jsonplaceholder.typicode.com/users"; ResClient client = new ResClient(); String body = "{ \"name\": \"John\", \"age\": 30 }"; String res = client.post(url, body); System.out.println(res); } public static void put() { String url = "https://jsonplaceholder.typicode.com/users/1"; ResClient client = new ResClient(); String body = "{ \"name\": \"John\", \"age\": 30 }"; String res = client.put(url, body); System.out.println(res); } public static void delete() { String url = "https://jsonplaceholder.typicode.com/users/1"; ResClient client = new ResClient(); String res = client.delete(url); System.out.println(res); } }