Skip to content
Browse files

Add respond_jsonp

  • Loading branch information...
1 parent 2710d06 commit 868ef9a29b75e19b2ea9876f905ff28077d0bad4 @andrewschaaf andrewschaaf committed Feb 9, 2014
Showing with 13 additions and 0 deletions.
  1. +8 −0 node-http-server.coffee
  2. +5 −0 test/test-respond_jsonp.coffee
View
8 node-http-server.coffee
@@ -13,6 +13,13 @@ respond_json = (res, code, x) ->
_respond_text res, code, 'application/json', JSON.stringify x, null, 2
+respond_jsonp = (req, res, x) ->
+ {callback} = req.query
+ text = JSON.stringify x, null, 2
+ text = "#{callback}(#{text})" if callback
+ _respond_text res, 200, 'text/javascript', text
+
+
respond_not_found = (res) ->
res.status(404).render('404')
@@ -64,6 +71,7 @@ module.exports = {
respond_error
respond_js
respond_json
+ respond_jsonp
respond_not_found
respond_storage_file
respond_plain
View
5 test/test-respond_jsonp.coffee
@@ -0,0 +1,5 @@
+assert = require 'assert'
+{respond_jsonp} = require '../index'
+
+describe "respond_jsonp", () ->
+ xit()

0 comments on commit 868ef9a

Please sign in to comment.
Something went wrong with that request. Please try again.