Skip to content

Commit 29e6c6a

Browse files
idmontieIvan
authored andcommitted
Add baseDir option and pass-through to ecstatic
Upgrade ecstatic to version 3.0.0. Use ecstatic's baseDir option to set a base directory. See #390
1 parent 9432968 commit 29e6c6a

File tree

2 files changed

+4
-0
lines changed

2 files changed

+4
-0
lines changed

bin/http-server

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ if (argv.h || argv.help) {
1818
'usage: http-server [path] [options]',
1919
'',
2020
'options:',
21+
' -b Base path [/]',
2122
' -p Port to use [8080]',
2223
' -a Address to use [0.0.0.0]',
2324
' -d Show directory listings [true]',
@@ -94,6 +95,7 @@ else {
9495

9596
function listen(port) {
9697
var options = {
98+
baseDir: argv.b,
9799
root: argv._[0],
98100
cache: argv.c,
99101
showDir: argv.d,

lib/http-server.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ function HttpServer(options) {
4343

4444
this.headers = options.headers || {};
4545

46+
this.baseDir = options.baseDir === undefined ? '/' : options.baseDir;
4647
this.cache = options.cache === undefined ? 3600 : options.cache; // in seconds.
4748
this.showDir = options.showDir !== 'false';
4849
this.autoIndex = options.autoIndex !== 'false';
@@ -94,6 +95,7 @@ function HttpServer(options) {
9495
}
9596

9697
before.push(ecstatic({
98+
baseDir: this.baseDir,
9799
root: this.root,
98100
cache: this.cache,
99101
showDir: this.showDir,

0 commit comments

Comments
 (0)