Skip to content

Commit

Permalink
Add API doc for context middleware - see #337
Browse files Browse the repository at this point in the history
  • Loading branch information
crandmck committed Nov 6, 2014
1 parent 21b2844 commit 3cdbd27
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
1 change: 1 addition & 0 deletions docs.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
16 changes: 15 additions & 1 deletion lib/middleware/context.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 3cdbd27

Please sign in to comment.