Skip to content
Myr

Added `res.json()` JSONP support. Closes #737

Before adoption: this commit came in with the history the project adopted, so no landing records it.

authored by Tj Holowaychuk · committed by Tj Holowaychuk · parent e7f2d22 · Browse files · 1 file+11 added−1 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

1 file+11 added−1 removed

  • other:+11 added−1 removed

1 file+11 added−1 removed

modified:lib/response.js+11 added-1 removed
133 unmodified lines
134 * @api public135 */136137res.json = function(obj, headers, status){138 var body = JSON.stringify(obj)139 , callback = this.req.query.callback140 , jsonp = this.app.enabled('jsonp callback');141142 this.charset = this.charset || 'utf-8';143 this.header('Content-Type', 'application/json');144145 if (callback && jsonp) {146 this.header('Content-Type', 'text/javascript');147 body = callback.replace(/[^\w$.]/g, '') + '(' + body + ');';148 }149140 return this.send(JSON.stringify(obj), headers, status);150 return this.send(body, headers, status);151};152153/**154 * Set status `code`.
317 unmodified lines