diff --git a/docs/api/index.md b/docs/api/index.md index 3c34165..8b7d82d 100644 --- a/docs/api/index.md +++ b/docs/api/index.md @@ -79,7 +79,6 @@ app.listen(3000); - `app.env` defaulting to the __NODE_ENV__ or "development" - `app.proxy` when true proxy header fields will be trusted - `app.subdomainOffset` offset of `.subdomains` to ignore [2] - - `app.jsonSpaces` default JSON response spaces [2] - `app.outputErrors` output err.stack to stderr [false in "test" environment] ## app.listen(...) diff --git a/docs/api/response.md b/docs/api/response.md index 399d187..86458f6 100644 --- a/docs/api/response.md +++ b/docs/api/response.md @@ -11,7 +11,7 @@ Response header object. ### res.socket - + Request socket. ### res.status @@ -130,15 +130,6 @@ so you can make a correction. The Content-Type is defaulted to application/json. -#### Notes - - To alter the JSON response formatting use the `app.jsonSpaces` - setting, for example to compress JSON responses set: - -```js -app.jsonSpaces = 0; -``` - ### res.get(field) Get a response header field value with case-insensitive `field`. @@ -257,7 +248,7 @@ this.response.etag = crypto.createHash('md5').update(this.body).digest('hex'); Append `val` to header `field`. ### res.vary(field) - + Vary on `field`. diff --git a/lib/application.js b/lib/application.js index 4d9df2e..5f8744c 100644 --- a/lib/application.js +++ b/lib/application.js @@ -40,7 +40,6 @@ function Application() { this.outputErrors = 'test' != this.env; this.subdomainOffset = 2; this.poweredBy = true; - this.jsonSpaces = 2; this.middleware = []; this.context = Object.create(context); this.request = Object.create(request); @@ -194,7 +193,7 @@ function *respond(next){ } // body: json - body = JSON.stringify(body, null, this.app.jsonSpaces); + body = JSON.stringify(body); this.length = Buffer.byteLength(body); if (head) return res.end(); res.end(body); diff --git a/test/application.js b/test/application.js index 6b81549..dafc068 100644 --- a/test/application.js +++ b/test/application.js @@ -409,26 +409,7 @@ describe('app.respond', function(){ request(server) .get('/') .expect('Content-Type', 'application/json') - .expect('{\n "hello": "world"\n}', done); - }) - - describe('when app.jsonSpaces is altered', function(){ - it('should reflect in the formatting', function(done){ - var app = koa(); - - app.jsonSpaces = 0; - - app.use(function *(){ - this.body = { hello: 'world' }; - }); - - var server = app.listen(); - - request(server) - .get('/') - .expect('Content-Type', 'application/json') - .expect('{"hello":"world"}', done); - }) + .expect('{"hello":"world"}', done); }) })