Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Removed `app.is()` support

  • Loading branch information...
commit edfe50e71398732c339f67a9c18eb8da6b88eb3b 1 parent 26fb403
@tj tj authored
Showing with 3 additions and 33 deletions.
  1. +0 −16 lib/application.js
  2. +3 −16 lib/request.js
  3. +0 −1  test/req.is.js
View
16 lib/application.js
@@ -43,7 +43,6 @@ app.init = function(){
this.cache = {};
this.settings = {};
this.engines = {};
- this.isCallbacks = {};
this.viewCallbacks = [];
this.defaultConfiguration();
@@ -292,21 +291,6 @@ app.param = function(name, fn){
};
/**
- * Register the given callback `fn` for the given `type`.
- *
- * @param {String} type
- * @param {Function} fn
- * @return {app} for chaining
- * @api public
- */
-
-app.is = function(type, fn){
- if (!fn) return this.isCallbacks[type];
- this.isCallbacks[type] = fn;
- return this;
-};
-
-/**
* Assign `setting` to `val`, or return `setting`'s value.
* Mounted servers inherit their parent server's settings.
*
View
19 lib/request.js
@@ -267,34 +267,23 @@ req.param = function(name, defaultValue){
* // With Content-Type: text/html; charset=utf-8
* req.is('html');
* req.is('text/html');
+ * req.is('text/*');
* // => true
*
* // When Content-Type is application/json
* req.is('json');
* req.is('application/json');
+ * req.is('application/*');
* // => true
*
* req.is('html');
* // => false
*
- * Ad-hoc callbacks can also be registered with Express, to perform
- * assertions again the request, for example if we need an expressive
- * way to check if our incoming request is an image, we can register "an image"
- * callback:
- *
- * app.is('an image', function(req){
- * return 0 == req.headers['content-type'].indexOf('image');
- * });
- *
- * app.is('an attachment', function(req){
- * return 0 == req.headers['content-disposition'].indexOf('attachment');
- * });
- *
* Now within our route callbacks, we can use to to assert content types
* such as "image/jpeg", "image/png", etc.
*
* app.post('/image/upload', function(req, res, next){
- * if (req.is('an image')) {
+ * if (req.is('image/*')) {
* // do something
* } else {
* next();
@@ -307,8 +296,6 @@ req.param = function(name, defaultValue){
*/
req.is = function(type){
- var fn = this.app.is(type);
- if (fn) return fn(this);
var ct = this.headers['content-type'];
if (!ct) return false;
ct = ct.split(';')[0];
View
1  test/req.is.js
@@ -5,7 +5,6 @@ var express = require('../')
function req(ct) {
var req = {
headers: { 'content-type': ct }
- , app: express()
, __proto__: express.request
};
Please sign in to comment.
Something went wrong with that request. Please try again.