kopia lustrzana https://github.com/c9/core
Simplify routing
rodzic
37286ec012
commit
7fabaaa51f
|
@ -132,15 +132,17 @@ module.exports = function Section(name, description, types) {
|
|||
*
|
||||
* Has a variable number of argumnets: no need to wrap handlers in an array
|
||||
*/
|
||||
this.on = function( path, handler ){
|
||||
var middlewares = Array.prototype.slice.call( arguments, 1 );
|
||||
this.on = function(path, handler){
|
||||
var middlewares = Array.prototype.slice.call(arguments, 1);
|
||||
handler = middlewares.shift();
|
||||
|
||||
middlewares.unshift(function(req, res, next){
|
||||
handler( req, res, next );
|
||||
middlewares.unshift(function(req, res, next) {
|
||||
handler(req, res, next);
|
||||
});
|
||||
|
||||
this._route( path, { method: "get" }, middlewares );
|
||||
this._route(path, {
|
||||
method: "get"
|
||||
}, middlewares);
|
||||
};
|
||||
|
||||
this._rootHandler = function(req, res) {
|
||||
|
@ -190,7 +192,7 @@ module.exports = function Section(name, description, types) {
|
|||
errorHandlers.unshift.apply(errorHandlers, handler.errorHandlers || []);
|
||||
handler = handler.parent;
|
||||
}
|
||||
|
||||
|
||||
if (this.globals.length)
|
||||
middleware.splice.apply( middleware, [1, 0].concat( this.globals ) );
|
||||
|
||||
|
|
Ładowanie…
Reference in New Issue