Skip to content
Myr

Merge pull request #1454 from shtylman/router-http-methods

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

add http verbs methods to Router

authored by TJ Holowaychuk · committed by TJ Holowaychuk · parents 64a2349, e4907ce · Browse files · 2 files+15 added−3 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+15 added−3 removed

  • other:+15 added−3 removed

2 files+15 added−3 removed

modified:lib/router/index.js+9 added
2 unmodified lines
3 */45var Route = require('./route')6 , utils = require('../utils')7 , methods = require('methods')8 , debug = require('debug')('express:router')9 , parse = require('connect').utils.parseUrl;1011/**
248 unmodified lines
260 // add it261 (this.map[method] = this.map[method] || []).push(route);262 return this;263};264265methods.forEach(function(method){266 Router.prototype[method] = function(path){267 var args = [method].concat([].slice.call(arguments));268 this.route.apply(this, args);269 return this;270 };271});
modified:lib/application.js+6 added-3 removed
395 unmodified lines
396 return this;397};398399/**400 * Delegate `.VERB(...)` calls to `.route(VERB, ...)`.400 * Delegate `.VERB(...)` calls to `router.VERB(...)`.401 */402403methods.forEach(function(method){404 app[method] = function(path){405 if ('get' == method && 1 == arguments.length) return this.set(path);406 var args = [method].concat([].slice.call(arguments));406407 // if no router attacked yet, attach the router408 if (!this._usedRouter) this.use(this.router);408 this._router.route.apply(this._router, args);409410 // setup route411 this._router[method].apply(this._router, arguments);412 return this;413 };414});415
118 unmodified lines