Added ability provide a filter function #828

Closed
wants to merge 1 commit into from

2 participants

@breck7

Let's say you didn't want to server a certain folder or type of file that you store in the public folder. This allows you to pass a callback that is just a more general version of the hidden filter.

Example to serve all files in a folder named 'public' except for text files:

app.use('/', express.static('public/', { filter: function (filename) { return filename.match(/\.txt/) } }))

I'm submitting a complementary patch to Send as well.

@breck7 breck7 Added ability provide a filter function
Let's say you didn't want to server a certain folder or type of file that you store in the public folder. This allows you to pass a callback that is just a more general version of the hidden filter.
0a28d0d
@breck7 breck7 referenced this pull request in pillarjs/send Jun 24, 2013
Closed

Update to support filter option #21

@breck7

Now that I think about it, I think this is a bad idea.

A better idea is to just drop a filter in express:

app.use('/private/', function (req, res) {
  return res.send('Sorry, it\'s private here.', 404)
})
app.use('/', express.static('public/'))
@tj
Sencha Labs member
tj commented Jul 6, 2013

yeah it's easy to use precedence or "wrapped" middleware to do this sort of thing

@tj tj closed this Jul 6, 2013
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment