Skip to content
Myr

remove old OPTIONS default response

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

relatively useless since its so non-informative, let me know if anyone has an objection to this, i think its best to define these for your API

authored by TJ Holowaychuk · committed by TJ Holowaychuk · parent 4403f13 · Browse files · 2 files+0 added−75 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+0 added−75 removed

  • tests:+0 added−37 removed
  • other:+0 added−38 removed

2 files+0 added−75 removed

modified:lib/router/index.js-38 removed
102 unmodified lines
103104 // match route105 req.route = route = self.matchRequest(req, i);106107 // implied OPTIONS108 if (!route && 'OPTIONS' == req.method) return self._options(req, res);109107 // no route108 if (!route) return next(err);109 debug('matched %s %s', route.method, route.path);110
59 unmodified lines
170 })(0);171};172173/**177 * Respond to __OPTIONS__ method.178 *179 * @param {IncomingMessage} req180 * @param {ServerResponse} res181 * @api private182 */183184Router.prototype._options = function(req, res){185 var path = parse(req).pathname186 , body = this._optionsFor(path).join(',');187 res.set('Allow', body).send(body);188};189190/**191 * Return an array of HTTP verbs or "options" for `path`.192 *193 * @param {String} path194 * @return {Array}195 * @api private196 */197198Router.prototype._optionsFor = function(path){199 var self = this;200 return methods.filter(function(method){201 var routes = self.map[method];202 if (!routes || 'options' == method) return;203 for (var i = 0, len = routes.length; i < len; ++i) {204 if (routes[i].match(path)) return true;205 }206 }).map(function(method){207 return method.toUpperCase();208 });209};210211/**174 * Attempt to match a route for `req`175 * with optional starting index of `i`176 * defaulting to 0.177 *
80 unmodified lines
deleted:test/app.options.js-37 removed