Allow for optional callback parameter in GET requests that return json formatted structures
-------------------------------------------------------------------------------------------
Key: GEOS-1411
URL: http://jira.codehaus.org/browse/GEOS-1411
Project: GeoServer
Issue Type: New Feature
Reporter: Tim Schaub
Assignee: Andrea Aime
Any GET request that returns JSON can be made into a flexible cross-domain accessible resource by accepting a "callback" parameter.
JSON wrapped in parentheses and prepended by some callback can become a JavaScript expression - and added dynamically to an application by appending a script tag.
Examples:
A current resource that responds to GET and accepts format=json or something similar
Request (abbreviated) -
GET /path/to/resource?format=json
Response (abbreviated) -
Content-Type: application/json
{"key": "value"}
If this resource accepts a callback parameter, things might look like this
Request -
GET /path/to/resource?format=json&callback=someFunc
Response
Content-Type: text/javascript
someFunc({"key": "value"})
So, the three steps are:
1) wrap JSON in parentheses
2) prepend with the callback string (any arbitrary string)
3) set content type to "text/javascript"
This allows people to specify function names as callbacks. It also allows something like
GET /path/to/resource?format=json&callback=var%20someVariable%20%3D%20
and the response would look like
var someVariable = ({"key": "value"})
(note that it is fine that the statement doesn't end with a semicolon in that case - it still makes for valid script contents)
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: http://jira.codehaus.org/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira