samu_masken #9
@ -5,6 +5,10 @@ import java.net.http.HttpClient;
|
|||||||
import java.net.http.HttpRequest;
|
import java.net.http.HttpRequest;
|
||||||
import java.net.http.HttpResponse;
|
import java.net.http.HttpResponse;
|
||||||
import java.nio.charset.StandardCharsets;
|
import java.nio.charset.StandardCharsets;
|
||||||
|
import java.nio.file.WatchEvent;
|
||||||
|
|
||||||
|
import Logik.Kind;
|
||||||
|
import com.google.gson.Gson;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* noch nicht getestet
|
* noch nicht getestet
|
||||||
@ -25,7 +29,7 @@ public class RestApiClient implements IRestAPI{
|
|||||||
|
|
||||||
public static void main(String[] args){
|
public static void main(String[] args){
|
||||||
|
|
||||||
new RestApiClient().get("Kind", 2);
|
new RestApiClient().get("Kind", 1);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -45,9 +49,12 @@ public class RestApiClient implements IRestAPI{
|
|||||||
// Send the request and get the response
|
// Send the request and get the response
|
||||||
HttpResponse<String> httpResponse = client.send(httpRequest, HttpResponse.BodyHandlers.ofString());
|
HttpResponse<String> httpResponse = client.send(httpRequest, HttpResponse.BodyHandlers.ofString());
|
||||||
|
|
||||||
|
Gson gson = new Gson();
|
||||||
|
Kind test = gson.fromJson(httpResponse.body(), Kind.class);
|
||||||
|
|
||||||
// Print the response status code and body
|
// Print the response status code and body
|
||||||
System.out.println("Status Code: " + httpResponse.statusCode());
|
System.out.println("Status Code: " + httpResponse.statusCode());
|
||||||
System.out.println("Response Body: " + httpResponse.body());
|
System.out.println("Response Body: " + test.getName());
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
|
@ -2,6 +2,7 @@ module de.subway_surfers.vpr_app {
|
|||||||
requires javafx.controls;
|
requires javafx.controls;
|
||||||
requires javafx.fxml;
|
requires javafx.fxml;
|
||||||
requires java.net.http;
|
requires java.net.http;
|
||||||
|
requires com.google.gson;
|
||||||
|
|
||||||
|
|
||||||
opens de.subway_surfers.vpr_app to javafx.fxml;
|
opens de.subway_surfers.vpr_app to javafx.fxml;
|
||||||
|
Loading…
Reference in New Issue
Block a user