cleanup WebRequest
Some checks failed
Deploy App / docker (ubuntu-latest, 2.44.0, 17, 3.8.5) (push) Failing after 24s

This commit is contained in:
Lee 2024-04-13 15:41:08 +01:00
parent 471c3e6e80
commit 57601acbb1
3 changed files with 3 additions and 5 deletions

@ -2,7 +2,6 @@ package cc.fascinated.common;
import lombok.AllArgsConstructor;
import lombok.Getter;
import org.springframework.http.HttpStatus;
import org.springframework.http.HttpStatusCode;
import java.util.List;

@ -35,7 +35,6 @@ public class WebRequest {
ResponseEntity<T> profile = CLIENT.get()
.uri(url)
.retrieve()
.onStatus(HttpStatusCode::isError, (request, response) -> {}) // Don't throw exceptions on error
.toEntity(clazz);
if (profile.getStatusCode().isError()) {
@ -53,11 +52,11 @@ public class WebRequest {
* @param url the url
* @return the response
*/
public static ResponseEntity<?> getAndIgnoreErrors(String url) {
public static ResponseEntity<?> get(String url, Class<?> clazz) {
return CLIENT.get()
.uri(url)
.retrieve()
.onStatus(HttpStatusCode::isError, (request, response) -> {}) // Don't throw exceptions on error
.toEntity(String.class);
.toEntity(clazz);
}
}

@ -192,7 +192,7 @@ public class MojangService {
Map<String, Boolean> endpoints = new HashMap<>();
for (EndpointStatus endpoint : MOJANG_ENDPOINTS) {
boolean online = false;
ResponseEntity<?> response = WebRequest.getAndIgnoreErrors(endpoint.getEndpoint());
ResponseEntity<?> response = WebRequest.get(endpoint.getEndpoint(), String.class);
if (endpoint.getAllowedStatuses().contains(response.getStatusCode())) {
online = true;
}