Permalink
Browse files

Add compatibility layer for new connect/send (fixes #43)

  • Loading branch information...
1 parent aa0b6cd commit 5c6816d2fbd14d177d315a1b013fcbdabb5f6ebc @Almad Almad committed Jul 9, 2012
Showing with 11 additions and 0 deletions.
  1. +11 −0 lib/staticGzip.js
View
11 lib/staticGzip.js
@@ -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`.
@@ -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);
}

0 comments on commit 5c6816d

Please sign in to comment.