Skip to content

Commit

Permalink
showDir as a parameter
Browse files Browse the repository at this point in the history
  • Loading branch information
James Halliday committed Nov 26, 2011
1 parent 7b5fd24 commit d0f5120
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
3 changes: 1 addition & 2 deletions example/express.js
Expand Up @@ -2,8 +2,7 @@ var express = require('express');
var ecstatic = require('../lib/ecstatic');

var app = express.createServer();
app.use(ecstatic(__dirname + '/public'));
app.use(ecstatic.showDir(__dirname + '/public'));
app.use(ecstatic(__dirname + '/public', { showDir : true }));
app.listen(8080);

console.log('Listening on :8080');
5 changes: 3 additions & 2 deletions lib/ecstatic.js
Expand Up @@ -11,7 +11,8 @@ var path = require('path'),

var ecstatic = module.exports = function (dir, opts) {
var root = path.resolve(dir) + '/',
cache = (opts && opts.cache) || 3600; // cache-ing time in seconds.
cache = (opts && opts.cache) || 3600, // cache-ing time in seconds.
shouldShowDir = (opts && opts.showDir);

return function middleware (req, res, next) {

Expand Down Expand Up @@ -39,7 +40,7 @@ var ecstatic = module.exports = function (dir, opts) {
status[500](res, next, { error: err });
}
else if (stat.isDirectory()) {
var handler = (typeof next === 'function')
var handler = (typeof next === 'function' && !shouldShowDir)
? next
: function () {
showDir(file, pathname, stat, cache)(req, res);
Expand Down

0 comments on commit d0f5120

Please sign in to comment.