Permalink
Browse files

Added jsonp support.

  • Loading branch information...
1 parent ef3b421 commit 8a3abf730d21ab3a8be5d6dcbcabe76293c83754 @Raynes committed Nov 1, 2011
Showing with 11 additions and 8 deletions.
  1. +11 −8 src/tryclojure/core.clj
View
@@ -139,14 +139,17 @@
(catch Exception e
{:error true :message (str (root-cause e))})))
-(defpage "/eval.json" {:keys [expr]}
- (json
- (let [{:keys [expr result error message] :as res} (eval-request expr)]
- (if error
- res
- (let [[out res] result]
- {:expr (pr-str expr)
- :result (str out (pr-str res))})))))
+(defpage "/eval.json" {:keys [expr jsonp]}
+ (update-in
+ (json
+ (let [{:keys [expr result error message] :as res} (eval-request expr)]
+ (if error
+ res
+ (let [[out res] result]
+ {:expr (pr-str expr)
+ :result (str out (pr-str res))}))))
+ [:body]
+ #(if jsonp (str jsonp "(" % ")") %)))
(server/add-middleware wrap-file (System/getProperty "user.dir"))

0 comments on commit 8a3abf7

Please sign in to comment.