Skip to content

Commit f7802f2

Browse files
committed
Options should all be implemented.
1 parent 5b579a5 commit f7802f2

File tree

3 files changed

+18
-9
lines changed

3 files changed

+18
-9
lines changed

lib/http-server.js

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@ var opts = {
1010
root: argv._[0] || "./public",
1111
port: argv.p || 8080,
1212
host: argv.a || 'localhost',
13-
cache: argv.c || 3600, // in seconds. TODO: add configurability to ecstatic
14-
autoIndex: argv.i || true, // TODO: add feature/configurability to ecstatic
13+
cache: argv.c || 3600, // in seconds.
14+
autoIndex: argv.i || true,
1515
silent: argv.s || argv.silent || false,
1616
help: argv.h || argv.help
1717
}
@@ -39,7 +39,12 @@ server.log = function (message) {
3939
}
4040

4141

42-
server.start = function () {
42+
server.start = function (overrides) {
43+
if (overrides) {
44+
Object.keys(overrides).forEach(function (k) {
45+
opts[k] = overrides[k];
46+
});
47+
}
4348

4449
if (opts.help) {
4550
return showHelp();
@@ -48,8 +53,10 @@ server.start = function () {
4853
//TODO: Add 404 file behavior to ecstatic, make configurable
4954
app.use(flatiron.plugins.http, {
5055
before: [
51-
ecstatic(opts.root),
52-
ecstatic.showDir(opts.root)
56+
ecstatic(opts.root, {
57+
autoIndex: opts.autoIndex,
58+
cache: opts.cache
59+
})
5360
]
5461
});
5562

package.json

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,10 @@
2323
"dependencies" : {
2424
"eyes": "~0.1.6",
2525
"colors" : "*",
26-
"optimist" : "0.2.x"
26+
"optimist" : "0.2.x",
27+
"flatiron": "0.1.x",
28+
"union": "0.1.x",
29+
"ecstatic": "0.1.x"
2730
},
2831
"analyze": false,
2932
"devDependencies": {

test/http-server-test.js

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,18 +3,17 @@ var assert = require('assert'),
33
fs = require('fs'),
44
vows = require('vows'),
55
request = require('request'),
6-
HTTPServer = require('../lib/http-server').HTTPServer;
6+
httpServer = require('../lib/http-server');
77

88
var root = path.join(__dirname, 'fixtures', 'root');
99

1010
vows.describe('http-server').addBatch({
1111
'When http-server is listening on 8080': {
1212
topic: function () {
13-
var httpServer = new HTTPServer({
13+
httpServer.start({
1414
port: 8080,
1515
root: root
1616
});
17-
httpServer.start();
1817
this.callback(null, httpServer);
1918
},
2019
'it should serve files from root directory': {

0 commit comments

Comments
 (0)