Support JSONP (by monkey-patching flask.jsonify).
ClosedPublic

Authored by ralph on Jun 4 2014, 9:31 PM.

Details

Summary

Monkey-patch flask.jsonify so that if a user specifies
?callback=callback in any URLs, then the results are returned as JSONP with
content type application/javascript.

This is needed by other web applications like Bodhi2 that want to query
resultsdb results from the clients' UI.

Fixes T207.

Test Plan
$ sudo yum install httpie

Start up resultsdb and then in another terminal run:

$ http get http://0.0.0.0:5000/api/v1.0
HTTP/1.0 404 NOT FOUND
Content-Length: 28
Content-Type: application/json
Date: Wed, 04 Jun 2014 21:30:19 GMT
Server: Werkzeug/0.9.4 Python/2.7.5

{
    "message": "Not found"
}

$ http get http://0.0.0.0:5000/api/v1.0\?callback\=wat
HTTP/1.0 404 NOT FOUND
Content-Length: 34
Content-Type: application/javascript
Date: Wed, 04 Jun 2014 21:30:26 GMT
Server: Werkzeug/0.9.4 Python/2.7.5

wat({
  "message": "Not found"
});

Diff Detail

Repository
rRSDB resultsdb
Branch
feature/jsonp
Lint
No Linters Available
Unit
No Unit Test Coverage
ralph retitled this revision from to Support JSONP (by monkey-patching flask.jsonify)..Jun 4 2014, 9:31 PM
ralph updated this object.
ralph edited the test plan for this revision. (Show Details)
ralph added reviewers: jskladan, tflink.
ralph added a task: T207: Support JSONP.
jskladan accepted this revision.Jun 6 2014, 6:24 AM

No objections here.

This revision is now accepted and ready to land.Jun 6 2014, 6:24 AM
ralph added a comment.Jun 7 2014, 6:28 PM

I can't seem to get 'arc land' to work.. :/

Can someone else merge this one?

ralph closed this revision.Jun 9 2014, 3:09 PM
ralph added a comment.Jun 9 2014, 3:09 PM

Nevermind -- got it. Thanks!