Comparing version 0.1.0 to 0.1.1
@@ -40,3 +40,18 @@ var path = require('path'), | ||
if (err && err.code === 'ENOENT') { | ||
status[404](res, next); | ||
// retry for ./404.html, if that's not there then return 404 | ||
// TODO: Make this pluggable/configurable. | ||
var handler = (typeof next === 'function' && !autoIndex) | ||
? next | ||
: function () { | ||
showDir(file, pathname, stat, cache)(req, res); | ||
}; | ||
middleware({ | ||
url: '/404.html', | ||
statusCode: 404 // Override the response | ||
}, res, function (req, res, next) { | ||
status[404](res, next); | ||
}); | ||
} | ||
@@ -83,3 +98,3 @@ else if (err) { | ||
if (req.method === "HEAD") { | ||
res.statusCode = 200; | ||
res.statusCode = req.statusCode || 200; // overridden for 404's | ||
res.end(); | ||
@@ -86,0 +101,0 @@ } |
@@ -23,3 +23,3 @@ var ecstatic = require('../ecstatic'), | ||
if (typeof cache === 'undefined') { | ||
cache = 3600*1000; | ||
cache = 3600; | ||
} | ||
@@ -26,0 +26,0 @@ |
@@ -31,3 +31,3 @@ exports['304'] = function (res, next) { | ||
else { | ||
res.statusCode = 404; | ||
if (res.writable) { | ||
@@ -34,0 +34,0 @@ res.setHeader('content-type', 'text/plain'); |
@@ -5,3 +5,3 @@ { | ||
"description": "A simple static file server middleware that works with both Express and Flatiron", | ||
"version": "0.1.0", | ||
"version": "0.1.1", | ||
"homepage": "https://github.com/jesusabdullah/node-ecstatic", | ||
@@ -8,0 +8,0 @@ "repository": { |
@@ -19,3 +19,2 @@ # Ecstatic | ||
app.use(ecstatic(__dirname + '/public')); | ||
app.use(ecstatic.showdir(__dirname + '/public')); | ||
app.listen(8080); | ||
@@ -35,3 +34,2 @@ | ||
ecstatic(__dirname + '/public'), | ||
ecstatic.showdir(__dirname + '/public') | ||
] | ||
@@ -51,3 +49,3 @@ }).listen(8080); | ||
Turn on directory listings from `ecstatic.showdir` with `opts.showdir === true`. | ||
Turn off directory listings with `opts.autoIndex === false`. | ||
@@ -58,5 +56,5 @@ ### middleware(req, res, next); | ||
## ecstatic.showdir(folder); | ||
## ecstatic.showDir(folder); | ||
This returns another middleware which will attempt to show a directory view. At the moment, you must add this explicitly for union and connect middleware stacks, so that one may chose actions other than showing a directory view if desired. | ||
This returns another middleware which will attempt to show a directory view. Turning on auto-indexing is roughly equivalent to adding this middleware after an ecstatic middleware with autoindexing disabled. | ||
@@ -67,8 +65,4 @@ # Tests: | ||
# Contributing: | ||
This is still "beta" quality, and you may find bugs. Please give me a heads-up if you find any! Pull requests encouraged. | ||
# License: | ||
MIT/X11. |
208844
351
64