From 7ee4f43dc0938a3f16bf68ba1dbbd05805dddc3d Mon Sep 17 00:00:00 2001 From: Jonathan Ong Date: Sun, 29 Dec 2013 22:16:04 -0800 Subject: [PATCH] docs: add debugging and ._name docs --- docs/guide.md | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/docs/guide.md b/docs/guide.md index 32e2034..d2adfff 100644 --- a/docs/guide.md +++ b/docs/guide.md @@ -211,3 +211,23 @@ $ DEBUG=koa* node --harmony examples/simple koa:application listen +0ms ``` + Since JavaScript does not allow defining function names at + runtime, you can also set a middleware's name as `._name`. + This useful when you don't have control of a middleware's name. + For example: + +```js +var path = require('path'); +var static = require('koa-static'); + +var publicFiles = static(path.join(__dirname, 'public')); +publicFiles._name = 'static /public'; + +app.use(publicFiles); +``` + + Now, instead of just seeing "static" when debugging, you will see: + +``` + koa:application use static /public +0ms +```