Skip to content
Myr

Added Express.eval()

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

authored by visionmedia · committed by visionmedia · parent 8efe00b · Browse files · 1 file+22 added−2 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+22 added−2 removed

  • other:+22 added−2 removed

1 file+22 added−2 removed

modified:lib/express.core.js+22 added-2 removed
263 unmodified lines
264 */265 266 callRouteFor : function(request) {267 var route = this.findRouteFor(request) || this.defaultRoute268 return eval('function(){ with (Express){' + Express.contentsOf(route.callback) + '}}')()268 if (route.keys)269 for (var i = 0, len = route.keys.length; i < len; ++i) 270 this.request.uri.params[route.keys[i]] = Express.captures[i] || null271 return this.eval(Express.contentsOf(route.callback))()272 },273 274 /**275 * Eval _string_ in context of Express.276 *277 * @param {string} string278 * @return {mixed}279 * @api public280 */281 282 eval : function(string) {283 return eval('function(){ with (Express){' + string + '}}')284 },285 286 /**287 * Attemp to find and return a route matching _request_.288 *289 * @param {object} request290 * @return {object}
34 unmodified lines
325 routeFunctionFor : function(method) {326 return function(path, callback) {327 if (typeof path == 'string') path = Express.normalizePath(path)328 Express.routes.push({314 path : path,329 keys : Express.regexpKeys || [],330 path : Express.pathToRegexp(path),331 method : method,332 callback : callback333 })334 }
17 unmodified lines
352post ('/users', function(){353 return 'Posted data'354})355356get ('/user/:name/edit', function(){357 return 'Editing user "' + (param('name') || 'none') + '"'358})359360Express.start()