Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
When using cross-domain requests, it is impossible to read the response data, and process it. Using JSONP allows a client, from a specific domain (for example /domain1), to query data in another doamin (/domain2), and analyze it, using a callback. Such a request would be followed by "callback=" parameter. For example: http://foreman-server:3000/statistics?format=json&callback=analyzeStats And the response would be: analyzeStats({"statistics":{"mem_totfree":0.0,"arch_count":{}, "env_count":{},"cpu_count":{},"mem_size":0,"swap_size":0, "model_count":{},"mem_free":0,"swap_free":0,"klass_count":{}, "os_count":{},"mem_totsize":0.0}}) which will call the analyzeStats callback. Whereas a regular request, http://foreman-server:3000/statistics?format=json, will just contain the JSON data. More reading on JSONP: JSONP - http://en.wikipedia.org/wiki/JSONP JSONP Ruby impl - www.simb.net/2012/02/06/ruby-and-jsonp https://github.com/crohr/rack-jsonp/
- Loading branch information
Showing
6 changed files
with
18 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
require 'config/settings' | ||
source 'http://rubygems.org' | ||
|
||
gem 'rails', '3.0.17' | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
group :jsonp do | ||
gem 'rack-jsonp', :require => 'rack/jsonp' | ||
end if SETTINGS[:support_jsonp] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
root = File.expand_path(File.dirname(__FILE__) + "/..") | ||
SETTINGS = YAML.load_file("#{root}/config/settings.yaml") | ||
SETTINGS[:version] = File.read(root + "/VERSION").chomp rescue ("N/A") | ||
SETTINGS[:unattended] = SETTINGS[:unattended].nil? || SETTINGS[:unattended] | ||
SETTINGS[:login] ||= SETTINGS[:ldap] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters