mirror of
https://github.com/eggjs/egg.git
synced 2024-12-04 07:14:30 +00:00
feat: [BREAKING_CHANGE] remove poweredBy && config.core (#63)
This commit is contained in:
parent
c356b04f4d
commit
7a17c0f1ae
@ -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
|
||||
|
||||
@ -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);
|
||||
};
|
||||
|
||||
@ -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
|
||||
*
|
||||
|
||||
@ -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>',
|
||||
@ -90,7 +89,6 @@ class EggApplication extends EggCore {
|
||||
'baseDir',
|
||||
'env',
|
||||
'subdomainOffset',
|
||||
'poweredBy',
|
||||
]);
|
||||
|
||||
abbr(res, this, [
|
||||
|
||||
@ -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',
|
||||
]);
|
||||
|
||||
@ -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('/')
|
||||
|
||||
@ -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');
|
||||
});
|
||||
});
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user