Skip to content
Myr

Evaulating routes in context to their given request instance

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

authored by visionmedia · committed by visionmedia · parent 0854753 · Browse files · 2 files+8 added−8 removed
This commit

State

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

Diff stats

2 files+8 added−8 removed

  • other:+8 added−8 removed

2 files+8 added−8 removed

modified:examples/app.js+3 added-3 removed
modified:lib/express/core.js+5 added-5 removed
44 unmodified lines
45 },46 47 /**48 * Execute this route's #fn with _args_,49 * returning it's return value.49 * against _context_ or GLOBAL.50 *51 * @param {array} args52 * @return {mixed}53 * @api private54 */55 56 run: function(args) {57 return this.fn.apply(GLOBAL, args)56 run: function(args, context) {57 return this.fn.apply(context || GLOBAL, args)58 },59 60 /**61 * Normalize _path_. When a RegExp it is simply returned,
47 unmodified lines
109 this.request = request110 },111 112 /**113 * Route #request returning the value returned by Route#run()113 * Evaluate the matched route against #request.114 *115 * @return {mixed}116 * @api private117 */118 119 route: function(){120 var route = this.matchingRoute()121 if (route)122 return route.run(this.request.captures.slice(1))122 return route.run(this.request.captures.slice(1), this.request)123 else if (this.request.accepts('html') && set('helpful 404'))124 this.request.halt(404, require('express/pages/not-found').render(this.request))125 else126 this.request.halt()
136 unmodified lines