cloudhead/node-static — pull request #82 by exos (2012-12-31 18:21:57+00:00)
Title: Listen method and prefix propertie

Hi!

I added a listen method, this is for implement the static server on instances of http server with anothers uses.

For example:

```
var http = require('http');
var io = require('socket.io');
var static = require('static').Server;

var httpd = http.createServer();

var sio = io.listen(httpd);
var staticServer = new static('./public');

staticServer.listen(httpd);

// Listen on port 8080, using socket.io and node-static
httpd.listen(8080);
```

To, you can only define the listen port:

```
var static = require('static').Server;

server = new static('./public');

server.listen(8080);
```

To, I added a prefix property for restrict waths is served:

```
var static = require('static').Server;

server = new static('.', {
prefix: '/static'
});

server.listen(8080);
```

The value of this propertie, can be a string or an regular expresion:

``````
var static = require('static').Server;

server = new static('.', {
prefix: /^\/(images|scripts|styles)\//
});

server.listen(8080);
```

or

``````
var static = require('static').Server;

server = new static('.', {
prefix: /\.(jpg|png|gif|ico|css|js|txt)$/i
});

server.listen(8080);
```

Sorry my english, I hope that changes served.