Skip to content

Commit

Permalink
Add compatibility layer for new connect/send (fixes tomgco#43)
Browse files Browse the repository at this point in the history
  • Loading branch information
Almad committed Jul 9, 2012
1 parent aa0b6cd commit 5c6816d
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions lib/staticGzip.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,16 @@ try {
} catch (e) {
staticSend = require('express').static.send;
}
if (!staticSend) {
// hack for the new connect where .send is extracted
// to send library and the helper is no longer directly exposed
staticMiddleware = require('connect').static;
staticSend = function(req, res, next, options) {
return staticMiddleware(
options.root, options
)(req, res, next);
}
}

/**
* Strip `Content-*` headers from `res`.
Expand Down Expand Up @@ -105,6 +115,7 @@ exports = module.exports = function staticGzip(dirPath, options){
var o = Object.create(options);
o.path = name;
o.maxAge = clientMaxAge;
o.root = dirPath;
staticSend(req, res, next, o);
}

Expand Down

0 comments on commit 5c6816d

Please sign in to comment.