Question

I've created a RESTful API that supports GET/POST/PUT/DELETE requests. Now I want my API to have a Javascript client library, and I thought to use JSONP to bypass the cross-domain policy. That works, but of course only for GET requests.

So I started thinking how to implement such a thing and at the same time trying to make it painless to use.

I thought to edit my API implementation and check every HTTP request. If it's a JSONP requests (it has a "callback" parameter in the querystring) I force every API method to be executed by a GET request, even if it should be called by other methods like POST or DELETE.

This is not a RESTful approach to the problem, but it works. What do you think?

Maybe another solution could be to dynamically generate an IFrame to send non-GET requests. Any tips?

No correct solution

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top