Permalink
Browse files

initial jsonp work from phromo's issue#8.

  • Loading branch information...
Robert Newson
Robert Newson committed Jul 11, 2009
1 parent 5077366 commit 358ec1f6bc52b7a92f31eef6060008fee12debb9
Showing with 7 additions and 1 deletion.
  1. +7 −1 src/main/java/com/github/rnewson/couchdb/lucene/SearchRequest.java
@@ -68,6 +68,8 @@
private final boolean rewrite_query;
+ private final String callback;
+
private final String ifNoneMatch;
public SearchRequest(final JSONObject obj, final String viewsig) throws ParseException {
@@ -84,6 +86,7 @@ public SearchRequest(final JSONObject obj, final String viewsig) throws ParseExc
this.debug = query.optBoolean("debug", false);
this.include_docs = query.optBoolean("include_docs", false);
this.rewrite_query = query.optBoolean("rewrite", false);
+ this.callback = query.optString("callback");
// Parse query.
this.q = Config.QP.parse(query.getString("q"));
@@ -252,7 +255,10 @@ public String execute(final IndexSearcher searcher) throws IOException {
headers.put("Content-Type", "text/plain");
result.put("body", escape(json.toString(2)));
} else {
- result.put("json", json);
+ if (callback != null)
+ result.put("json", String.format("%s(%s)", callback, json));
+ else
+ result.put("json", json);
}
// Include headers.

0 comments on commit 358ec1f

Please sign in to comment.