Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: remove overrideMethod middleware #324

Merged
merged 1 commit into from
Feb 7, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion app/middleware/notfound.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,5 @@ module.exports = options => {
} else {
this.body = title;
}

};
};
3 changes: 0 additions & 3 deletions app/middleware/override_method.js

This file was deleted.

4 changes: 2 additions & 2 deletions app/middleware/site_file.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@ const MAX_AGE = 'public, max-age=2592000'; // 30 days
module.exports = options => {
return function* siteFile(next) {
if (this.method !== 'HEAD' && this.method !== 'GET') return yield next;

if (!options.hasOwnProperty(this.path)) return yield next;
if (this.path[0] !== '/') return yield next;
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

加个字符串判断,就不担心 hasOwnProperty 被入注了


const content = options[this.path];
if (!content) return yield next;

// '/favicon.ico': 'https://eggjs.org/favicon.ico',
// content is url
Expand Down
3 changes: 1 addition & 2 deletions config/config.default.js
Original file line number Diff line number Diff line change
Expand Up @@ -204,15 +204,14 @@ module.exports = appInfo => {
};

/**
* 定义 core 中间件加载的顺序,中间件的名称会映射到 app.middlewares
* core enable middlewares
* @member {Array} Config#middleware
*/
exports.coreMiddleware = [
'meta',
'siteFile',
'notfound',
'bodyParser',
'overrideMethod',
];

/**
Expand Down
1 change: 0 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@
"is-type-of": "^1.0.0",
"koa-bodyparser": "^2.3.0",
"koa-is-json": "^1.0.0",
"koa-override": "^1.0.0",
"mime-types": "^2.1.14",
"sendmessage": "^1.1.0",
"urllib": "^2.20.0"
Expand Down
37 changes: 0 additions & 37 deletions test/app/middleware/override_method.test.js

This file was deleted.

13 changes: 0 additions & 13 deletions test/fixtures/apps/override_method/app/router.js

This file was deleted.

8 changes: 0 additions & 8 deletions test/fixtures/apps/override_method/config/config.default.js

This file was deleted.

3 changes: 0 additions & 3 deletions test/fixtures/apps/override_method/package.json

This file was deleted.

2 changes: 1 addition & 1 deletion test/lib/core/loader/config_loader.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ describe('test/lib/core/loader/config_loader.test.js', () => {
'notfound',
'static',
'bodyParser',
'overrideMethod',
'userservice',
]);
});

Expand Down