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