Simple image host.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

favicon.node.js 504B

12345678910111213141516171819202122232425262728
  1. var fs = require("fs");
  2. var zlib = require("zlib");
  3. var gzipped;
  4. var favicon = fs.readFileSync("favicon.ico");
  5. zlib.gzip(favicon, function(err, res) {
  6. gzipped = res;
  7. });
  8. module.exports = function(ctx) {
  9. if (favicon) {
  10. ctx.res.setHeader(
  11. "Cache-Control",
  12. "public, max-age="+ctx.conf.cache_max_age
  13. );
  14. }
  15. if (gzipped && ctx.shouldGzip) {
  16. ctx.res.setHeader("Content-Encoding", "gzip");
  17. ctx.res.end(gzipped);
  18. } else if (favicon) {
  19. ctx.res.end(favicon);
  20. } else {
  21. ctx.err404();
  22. }
  23. }