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: [BREAKING_CHANGE] remove poweredBy && config.core #63

Merged
merged 1 commit into from
Aug 29, 2016
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
10 changes: 0 additions & 10 deletions app/extend/application.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,16 +53,6 @@ module.exports = {
return context;
},

/**
* X-Powered-By Header
* @member {String} Application#poweredBy
* @private
* @since 1.0.0
*/
get poweredBy() {
return this.config.core.name;
},

/**
* Service 基类
* @member {Service} Application#Service
Expand Down
7 changes: 1 addition & 6 deletions app/middleware/meta.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,9 @@

'use strict';

module.exports = (_, app) => {
const poweredBy = typeof app.poweredBy === 'string' ? app.poweredBy : null;

module.exports = () => {
return function* meta(next) {
if (poweredBy) this.setRawHeader('X-Powered-By', poweredBy);

yield next;

// total response time header
this.setRawHeader('X-Readtime', Date.now() - this.starttime);
};
Expand Down
9 changes: 0 additions & 9 deletions config/config.default.js
Original file line number Diff line number Diff line change
Expand Up @@ -69,15 +69,6 @@ module.exports = appInfo => {
rundir: path.join(appInfo.baseDir, 'run'),
};

/**
* Framework name
* @member {Object} Config#core
* @property {String} name - 'Egg' by default
*/
exports.core = {
name: 'Egg',
};

/**
* notfound 中间件 options
*
Expand Down
2 changes: 0 additions & 2 deletions lib/egg.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,6 @@ class EggApplication extends EggCore {
* name: 'mockapp',
* env: 'test',
* subdomainOffset: 2,
* poweredBy: 'egg/1.0.0',
* config: '<egg config>',
* controller: '<egg controller>',
* service: '<egg service>',
Expand Down Expand Up @@ -90,7 +89,6 @@ class EggApplication extends EggCore {
'baseDir',
'env',
'subdomainOffset',
'poweredBy',
]);

abbr(res, this, [
Expand Down
2 changes: 1 addition & 1 deletion test/lib/core/app/extend/application.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ describe('test/lib/core/app/extend/application.test.js', () => {
app.ready(() => {
app.inspect().should.have.properties([
'name', 'baseDir',
'env', 'subdomainOffset', 'poweredBy',
'env', 'subdomainOffset',
'controller', 'middlewares', 'serviceClasses',
'config', 'urllib', 'loggers',
]);
Expand Down
14 changes: 0 additions & 14 deletions test/lib/core/app/middleware/meta.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,20 +15,6 @@ describe('test/lib/core/app/middleware/meta.test.js', () => {

afterEach(mm.restore);

it('should get X-Powered-By header', () => {
return request(app.callback())
.get('/')
.expect('X-Powered-By', 'Egg')
.expect(200);
});

it('should still get X-Powered-By header when controller error', () => {
return request(app.callback())
.get('/error')
.expect('X-Powered-By', 'Egg')
.expect(500);
});

it('should get X-Readtime header', () => {
return request(app.callback())
.get('/')
Expand Down
4 changes: 2 additions & 2 deletions test/lib/core/config/config.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ describe('test/lib/core/config/config.test.js', () => {

afterEach(mm.restore);

it('should return config.core.name that is deprecated', () => {
app.config.core.name.should.equal('Egg');
it('should return config.name', () => {
app.config.name.should.equal('demo');
});
});