var fs = require('fs'),
    util = require('util'),
    union = require('union'),
    ecstatic = require('ecstatic');

var HTTPServer = exports.HTTPServer = function (options) {
  options = options || {};

  if (options.root) {
    this.root = options.root;
  }
  else {
    try {
      fs.lstatSync('./public');
      this.root = './public';
    }
    catch (err) {
      this.root = './';
    }
  }
  
  if (options.headers) {
    this.headers = options.headers; 
  }

  this.cache = options.cache || 3600; // in seconds.
  this.autoIndex = options.autoIndex !== false;

  if (options.ext) {
    this.ext = options.ext === true
      ? 'html'
      : options.ext;
  }

  this.server = union.createServer({
    before: (options.before || []).concat([
      ecstatic(this.root, {
        autoIndex: this.autoIndex,
        cache: this.cache,
        defaultExt: this.ext
      })
    ]),
    headers: this.headers || {}
  });
};

HTTPServer.prototype.listen = function () {
  this.server.listen.apply(this.server, arguments);
};

HTTPServer.prototype.close = function () {
  return this.server.close();
};

exports.createServer = function (options) {
  return new HTTPServer(options);
};

@@ -517,16 +517,62 @@
 econds.%0A
+  this.showDir = options.showDir !== 'false';%0A
   this.a
@@ -604,21 +604,23 @@
 dex !== 
+'
 false
+'
 ;%0A%0A  if 
@@ -808,16 +808,32 @@
 cstatic(
+%7B%0A        root: 
 this.roo
@@ -834,18 +834,16 @@
 is.root,
- %7B
 %0A       
@@ -847,60 +847,92 @@
     
-autoIndex: this.autoIndex,%0A        cache: this.cache
+cache: this.cache,%0A        showDir : this.showDir,%0A        autoIndex: this.autoIndex
 ,%0A  

implement showDir option; autoIndex and showDir should test against 'false' not false