« index
Coverage for /Users/yunong/workspace/node-restify/lib/plugins/jsonp.js : 100%
26 lines |
26 run |
0 missing |
0 partial |
4 blocks |
4 blocks run |
0 blocks missing
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 | // Copyright 2012 Mark Cavage, Inc. All rights reserved. var qs = require('qs'); ///--- API function jsonp() { function _jsonp(req, res, next) { var q = req.getQuery(); // If the query plugin wasn't used, we need to hack it in now if (typeof (q) === 'string') req.query = qs.parse(q); if (req.query.callback || req.query.jsonp) res.setHeader('Content-Type', 'application/javascript'); next(); } return (_jsonp); } module.exports = jsonp; |