// do compression
Reader in = new BufferedReader(new InputStreamReader(inputStream));
if (this.key.endsWith(".js?minify") || this.key.endsWith(".json?minify")) {
try {
JavaScriptCompressor compressor = new JavaScriptCompressor(in, null);
// boolean options: munge, verbose, preserveAllSemiColons, disableOptimizations
compressor.compress(outWriter, MINIFY_LINEBREAKPOS, true, false, false, false);
} catch (EvaluatorException e) {
// fail gracefully on malformed javascript: send it without compressing
normalOutput(inputStream);
return;
}
} else if (this.key.endsWith(".css?minify")) {
CssCompressor compressor = new CssCompressor(in);
compressor.compress(outWriter, MINIFY_LINEBREAKPOS);
} else {
// or not if not right type
normalOutput(inputStream);
return;
}