Add API doc for context middleware - see #337
This commit is contained in:
parent
21b28446bf
commit
3cdbd274d2
|
@ -9,6 +9,7 @@
|
||||||
"lib/model.js",
|
"lib/model.js",
|
||||||
"lib/persisted-model.js",
|
"lib/persisted-model.js",
|
||||||
{ "title": "Middleware", "depth": 2 },
|
{ "title": "Middleware", "depth": 2 },
|
||||||
|
"lib/middleware/context.js",
|
||||||
"lib/middleware/rest.js",
|
"lib/middleware/rest.js",
|
||||||
"lib/middleware/static.js",
|
"lib/middleware/static.js",
|
||||||
"lib/middleware/status.js",
|
"lib/middleware/status.js",
|
||||||
|
|
|
@ -25,6 +25,20 @@ function createContext(scope) {
|
||||||
return ns;
|
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) {
|
function context(options) {
|
||||||
options = options || {};
|
options = options || {};
|
||||||
var scope = options.name || name;
|
var scope = options.name || name;
|
||||||
|
@ -62,7 +76,7 @@ function ChainedContext(child, parent) {
|
||||||
this.parent = parent;
|
this.parent = parent;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/*!
|
||||||
* Get the value by name from the context. If it doesn't exist in the child
|
* Get the value by name from the context. If it doesn't exist in the child
|
||||||
* context, try the parent one
|
* context, try the parent one
|
||||||
* @param {String} name Name of the context property
|
* @param {String} name Name of the context property
|
||||||
|
|
Loading…
Reference in New Issue