Method: Rack::JSONP#pad
- Defined in:
- lib/rack/contrib/jsonp.rb
#pad(callback, response, body = "") ⇒ Object
Pads the response with the appropriate callback format according to the JSON-P spec/requirements.
The Rack response spec indicates that it should be enumerable. The method of combining all of the data into a single string makes sense since JSON is returned as a full string.
35 36 37 38 |
# File 'lib/rack/contrib/jsonp.rb', line 35 def pad(callback, response, body = "") response.each{ |s| body << s.to_s } "#{callback}(#{body})" end |