Skip to content
Myr

Changed `app.locals` to match `res.locals`

Before adoption: this commit came in with the history the project adopted, so no landing records it.

authored by Tj Holowaychuk · committed by Tj Holowaychuk · parent cd88b92 · Browse files · 1 file+17 added−34 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

1 file+17 added−34 removed

  • other:+17 added−34 removed

1 file+17 added−34 removed

modified:lib/http.js+17 added-34 removed
61 unmodified lines
62 this.cache = {};63 this.settings = {};64 this.redirects = {};65 this.isCallbacks = {};66 this._locals = {};6667 this.set('home', '/');68 this.set('env', process.env.NODE_ENV || 'development');69 this.use(connect.query());7071 /**72 * Assign several locals with the given `obj`,73 * or return the locals.74 *75 * @param {Object} obj76 * @return {Object|HTTPServer}77 * @api public78 */7980 this.locals = function(obj){81 for (var key in obj) {82 self.locals[key] = obj[key];83 }84 return self;85 };8687 // expose objects to each other88 this.use(function(req, res, next){89 var charset;90 req.query = req.query || {};
18 unmodified lines
109 res.locals = function(obj){110 for (var key in obj) {111 res.locals[key] = obj[key];112 }113 return res;114 };115116 next();117 });
167 unmodified lines
285 return this;286};287288/**273 * Assign the view local variable `name` to `val` or return the274 * local previously assigned to `name`.275 *276 * @param {String} name277 * @param {Mixed} val278 * @return {HTTPServer} for chaining279 * @api public280 */281282app.local = function(name, val){283 if (1 == arguments.length) return this._locals[name];284 this._locals[name] = val;285 return this;286};287288/**289 * Assign several locals with the given `obj`,290 * or return the locals.291 *292 * @param {Object} obj293 * @return {Object|HTTPServer}294 * @api public295 */296297app.locals = function(obj){298 if (0 == arguments.length) return this._locals;299 for (var key in obj) {300 this.local(key, obj[key]);301 }302 return this;303};304305/**289 * Map the given param placeholder `name`(s) to the given callback `fn`.290 *291 * Param mapping is used to provide pre-conditions to routes292 * which us normalized placeholders. This callback has the same
212 unmodified lines