Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
ApiSettings getApiSettings() {
// TODO: currently, any setting in both a base and env config will be overridden by the last
// definition. e.g. a setting in api.yaml and env/api.yaml will take the definition in
// env/api.yaml. Determine whether this is intended behavior.
try {
ImmutableList<String> settingsFiles = ImmutableList.<String>builder()
// ApiSettings apiSettings = getApiSettings(settingsFiles);
String tempSettings = "baseUrl: http://localhost:3000\nbaseApiUrl: http://localhost:8080\n";
InputStream in = new ByteArrayInputStream(tempSettings.getBytes(StandardCharsets.UTF_8));
ApiSettings apiSettings = getApiSettings(in);
logger.debug("Parsed flags: {}", apiSettings);
return apiSettings;
} catch (IOException e) {
throw new IllegalArgumentException("Problem parsing api settings", e);
static ApiSettings getApiSettings(ImmutableList<String> settingsFiles) throws IOException {
InputStream combinedInputStream = ConfigUtils.getSettingsCombinedInputStream(settingsFiles);
return getApiSettings(combinedInputStream);
static ApiSettings getApiSettings(InputStream inputStream) {
ObjectMapper mapper = new ObjectMapper(new YAMLFactory());
return mapper.readValue(combinedInputStream, ApiSettings.class);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.