Skip to content

Commit

Permalink
remove old OPTIONS default response
Browse files Browse the repository at this point in the history
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
  • Loading branch information
tj committed Aug 29, 2012
1 parent 4403f13 commit 2bba69f
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 75 deletions.
38 changes: 0 additions & 38 deletions lib/router/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -104,9 +104,6 @@ Router.prototype._dispatch = function(req, res, next){
// match route
req.route = route = self.matchRequest(req, i);

// implied OPTIONS
if (!route && 'OPTIONS' == req.method) return self._options(req, res);

// no route
if (!route) return next(err);
debug('matched %s %s', route.method, route.path);
Expand Down Expand Up @@ -173,41 +170,6 @@ Router.prototype._dispatch = function(req, res, next){
})(0);
};

/**
* Respond to __OPTIONS__ method.
*
* @param {IncomingMessage} req
* @param {ServerResponse} res
* @api private
*/

Router.prototype._options = function(req, res){
var path = parse(req).pathname
, body = this._optionsFor(path).join(',');
res.set('Allow', body).send(body);
};

/**
* Return an array of HTTP verbs or "options" for `path`.
*
* @param {String} path
* @return {Array}
* @api private
*/

Router.prototype._optionsFor = function(path){
var self = this;
return methods.filter(function(method){
var routes = self.map[method];
if (!routes || 'options' == method) return;
for (var i = 0, len = routes.length; i < len; ++i) {
if (routes[i].match(path)) return true;
}
}).map(function(method){
return method.toUpperCase();
});
};

/**
* Attempt to match a route for `req`
* with optional starting index of `i`
Expand Down
37 changes: 0 additions & 37 deletions test/app.options.js

This file was deleted.

0 comments on commit 2bba69f

Please sign in to comment.