Created
December 14, 2012 23:40
-
-
Save geddski/4289625 to your computer and use it in GitHub Desktop.
example of using express middleware to gzip xml files
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
var express = require('express'); | |
var connect = require('connect'); | |
var zlib = require('zlib'); | |
var fs = require('fs'); | |
var app = express(); | |
var compressOptions = { | |
filter: function(req, res) { | |
return /json|text|xml|javascript/.test(res.getHeader('Content-Type')) | |
} | |
}; | |
app.use(express.compress(compressOptions)); | |
app.use(express.static(__dirname + '/public')); | |
app.get('/', function(req, res){ | |
res.sendfile('./public/data.xml'); | |
}); | |
app.listen(8000); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment