From 1605f33760ed2cf5a4a63cfbc4d73db9eecd9684 Mon Sep 17 00:00:00 2001 From: Jonathan Ong Date: Sat, 2 Aug 2014 04:10:07 -0700 Subject: [PATCH] add context.inspect(), cleanup app.inspect() closes #323 closes #250 --- lib/application.js | 2 ++ lib/context.js | 19 ++++++++++++++++++- 2 files changed, 20 insertions(+), 1 deletion(-) diff --git a/lib/application.js b/lib/application.js index c57d541..b26f354 100644 --- a/lib/application.js +++ b/lib/application.js @@ -72,11 +72,13 @@ app.listen = function(){ /** * Return JSON representation. + * We only bother showing settings. * * @return {Object} * @api public */ +app.inspect = app.toJSON = function(){ return only(this, [ 'subdomainOffset', diff --git a/lib/context.js b/lib/context.js index 2b0b084..02b85d5 100644 --- a/lib/context.js +++ b/lib/context.js @@ -13,6 +13,18 @@ var http = require('http'); var proto = module.exports = { + /** + * util.inspect() implementation, which + * just returns the JSON output. + * + * @return {Object} + * @api public + */ + + inspect: function(){ + return this.toJSON(); + }, + /** * Return JSON representation. * @@ -28,7 +40,12 @@ var proto = module.exports = { toJSON: function(){ return { request: this.request.toJSON(), - response: this.response.toJSON() + response: this.response.toJSON(), + app: this.app.toJSON(), + originalUrl: this.originalUrl, + req: '', + res: '', + socket: '', } },