expressjs / serve-static

Serve static files
MIT License
1.39k stars 228 forks source link

Update index.js, adding new option. #19

Closed CrackerakiUA closed 9 years ago

CrackerakiUA commented 9 years ago

This option have name access and it's for security of given static files. This option can be true if user give Boolean true or dont give anything or false if user give Boolean false or anything else. Examples below:

app.use(express.static(dirname + '/public', {access: true} )); // show folder app.use(express.static(dirname + '/public' )); // show folder app.use(express.static(dirname + '/public', {access: false} )); // do not show folder app.use(express.static(dirname + '/public', {access: 'asdqw2'} )); // do not show folder

dougwilson commented 9 years ago

No. The solution is to implement a middleware wrapper; this option is pure feature float. Example:

var serve = express.static(__dirname + '/public')

app.use(function (req, res, next) {
  if (!access) return next()
  serve(req, res, next)
})