cxf-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Sergey Beryozkin <sberyoz...@gmail.com>
Subject Re: JSONP interceptors
Date Sun, 29 Aug 2010 14:03:05 GMT
Hi Josh

On Sun, Aug 29, 2010 at 3:12 AM, Josh Holtzman <jholtzman@berkeley.edu>wrote:

> With some help from sergeyb and dkulp yesterday, I wrote some very simple
> CXF interceptors that enable transparent JSONP capabilities in JAX-RS.  If
> a
> request contains a "jsonp" parameter in the querystring, and the response's
> content type is "application/json", the response is wrapped in the callback
> specified by the jsonp parameter.
>
> For example, a response from a hypothetical JAX-RS endpoint at /foo.json
> looks like this:
>
> {"foo":"bar"}
>
> The response to the same URL with a jsonp parameter
> (/foo.json?jsonp=handleCallback) would look like this:
>
> handleCallback({"foo":"bar"})
>
> With jsonp, the /foo.json service can be called from 3rd party
> browser-based
> mashups.  Without it, browsers' same-origin policy limits the usefulness of
> the endpoint.  If there is interest in including this functionality in CXF
> itself, I'd be happy to submit a patch.
>
> Sounds good - please do :-).
One thing is that the policy which has been followed so far by the JAXRS
module is that query parameters which are meant for the runtime
interceptors/filters are prepended with "_". If you prefer just "jsonp" as
opposed to "_jsonp" then it's fine, but I;d be nice if _jsonp was also
supported, just so that users could do say
/foo?_type=json&_jsonp=handleCallback, where /foo?_type=json is equivalent
to /foo.json

thanks, Sergey


> Thanks,
> Josh
>

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message