Skip to content

Commit

Permalink
Merge pull request #56 from blakmatrix/patch-1
Browse files Browse the repository at this point in the history
[doc] Updates for clarity and reading ease
  • Loading branch information
jfhbrook committed Dec 29, 2012
2 parents dc0ff5e + b958530 commit 20b509d
Showing 1 changed file with 31 additions and 4 deletions.
35 changes: 31 additions & 4 deletions README.md
Expand Up @@ -61,34 +61,61 @@ ecstatic({ root: __dirname + '/public', handleError: false })


Pass ecstatic an options hash, and it will return your middleware! Pass ecstatic an options hash, and it will return your middleware!


```js
var opts = {
root : __dirname + '/public',
baseDir : '/',
cache : 3600,
showDir : false,
autoIndex : false,
defaultExt : 'html',
gzip : false
}
```

### `opts.root`

`opts.root` is the directory you want to serve up. `opts.root` is the directory you want to serve up.


### `opts.baseDir`

`opts.baseDir` is `/` by default, but can be changed to allow your static files `opts.baseDir` is `/` by default, but can be changed to allow your static files
to be served off a specific route. For example, if `opts.baseDir === "blog"` to be served off a specific route. For example, if `opts.baseDir === "blog"`
and `opts.root = "./public"`, requests for `localhost:8080/blog/index.html` will and `opts.root = "./public"`, requests for `localhost:8080/blog/index.html` will
resolve to `./public/index.html`. resolve to `./public/index.html`.


### `opts.cache`

Customize cache control with `opts.cache`, in seconds. Time defaults to 3600 s Customize cache control with `opts.cache`, in seconds. Time defaults to 3600 s
(ie, 1 hour). (ie, 1 hour).


Turn **on** directory listings with `opts.showDir === true`. Turn **on** ### `opts.showDir`
autoIndexing with `opts.autoIndex === true`. Defaults to **false**.
Turn **on** directory listings with `opts.showDir === true`.

### `opts.autoIndex`

Turn **on** autoIndexing with `opts.autoIndex === true`. Defaults to **false**.

### `opts.defaultExt`


Turn on default file extensions with `opts.defaultExt`. If `opts.defaultExt` is Turn on default file extensions with `opts.defaultExt`. If `opts.defaultExt` is
true, it will default to `html`. For example if you want a request to `/a-file` true, it will default to `html`. For example if you want a request to `/a-file`
to resolve to `./public/a-file.html`, set this to `true`. If you want to resolve to `./public/a-file.html`, set this to `true`. If you want
`/a-file` to resolve to `./public/a-file.json` instead, set `opts.defaultExt` to `/a-file` to resolve to `./public/a-file.json` instead, set `opts.defaultExt` to
`json`. `json`.


### `opts.gzip`

Set `opts.gzip === true` in order to turn on "gzip mode," wherein ecstatic will Set `opts.gzip === true` in order to turn on "gzip mode," wherein ecstatic will
serve `./public/some-file.js.gz` in place of `./public/some-file.js` when the serve `./public/some-file.js.gz` in place of `./public/some-file.js` when the
gzipped version exists and ecstatic determines that the behavior is appropriate. gzipped version exists and ecstatic determines that the behavior is appropriate.


### middleware(req, res, next); ## middleware(req, res, next);


This works more or less as you'd expect. This works more or less as you'd expect.


## ecstatic.showDir(folder); ### ecstatic.showDir(folder);


This returns another middleware which will attempt to show a directory view. Turning on auto-indexing is roughly equivalent to adding this middleware after an ecstatic middleware with autoindexing disabled. This returns another middleware which will attempt to show a directory view. Turning on auto-indexing is roughly equivalent to adding this middleware after an ecstatic middleware with autoindexing disabled.


Expand Down

0 comments on commit 20b509d

Please sign in to comment.