Add API doc for context middleware - see #337

This commit is contained in:
crandmck 2014-11-06 14:07:34 -08:00
parent 21b28446bf
commit 3cdbd274d2
2 changed files with 16 additions and 1 deletions

View File

@ -9,6 +9,7 @@
"lib/model.js",
"lib/persisted-model.js",
{ "title": "Middleware", "depth": 2 },
"lib/middleware/context.js",
"lib/middleware/rest.js",
"lib/middleware/static.js",
"lib/middleware/status.js",

View File

@ -25,6 +25,20 @@ function createContext(scope) {
return ns;
}
/**
* Context middleware.
* ```js
* var app = loopback();
* app.use(loopback.context(options);
* app.use(loopback.rest());
* app.listen();
* ```
* @options {Object} [options] Options for context
* @property {String} name Context scope name.
* @property {Boolean} enableHttpContext Whether HTTP context is enabled. Default is false.
* @header loopback.context([options])
*/
function context(options) {
options = options || {};
var scope = options.name || name;
@ -62,7 +76,7 @@ function ChainedContext(child, parent) {
this.parent = parent;
}
/**
/*!
* Get the value by name from the context. If it doesn't exist in the child
* context, try the parent one
* @param {String} name Name of the context property