-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(hosts-xml-missing): Fix issue when Vispana fails to load hosts.xm…
…l, when not available (#48) Co-authored-by: Broknloop <broknloop@gmail.com>
- Loading branch information
1 parent
196ffe6
commit efb6322
Showing
4 changed files
with
34 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
11 changes: 11 additions & 0 deletions
11
src/main/java/com/vispana/client/vespa/helpers/Request.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,22 @@ | ||
package com.vispana.client.vespa.helpers; | ||
|
||
import java.util.Optional; | ||
import org.springframework.web.client.RestClient; | ||
|
||
public class Request { | ||
|
||
private static final RestClient restClient = RestClient.create(); | ||
|
||
public static <T> T request(String url, Class<T> responseType) { | ||
return restClient.get().uri(url).retrieve().body(responseType); | ||
} | ||
|
||
public static <T> Optional<T> requestWithDefaultValue( | ||
String url, Class<T> responseType, T defaultValue) { | ||
try { | ||
return Optional.of(request(url, responseType)); | ||
} catch (Exception exception) { | ||
return Optional.of(defaultValue); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters