use of org.finos.waltz.service.settings.SettingsService in project waltz by khartec.
the class Main method enableGZIP.
private void enableGZIP() {
SettingsService settingsService = ctx.getBean(SettingsService.class);
Boolean gzipEnabled = settingsService.getValue(GZIP_ENABLED_NAME).map(x -> x.equalsIgnoreCase("true")).orElse(false);
if (gzipEnabled) {
// now fetch the minimum size
int minimumLength = settingsService.getValue(GZIP_MIN_SIZE_NAME).map(Integer::parseInt).orElse(8192);
after(((request, response) -> {
if (response.body() != null && response.body().length() >= minimumLength) {
response.header("Content-Encoding", "gzip");
}
}));
LOG.info("Enabled GZIP (size: " + minimumLength + ")");
} else {
LOG.info("GZIP not enabled");
}
}
Aggregations