Permalink
Browse files

Use jsonp from noir.response.

  • Loading branch information...
Raynes committed Nov 29, 2011
1 parent 006cb69 commit 8e132f046391b1c5fb2a383154f02ccf2f4a35ad
Showing with 12 additions and 12 deletions.
  1. +12 −12 src/tryclojure/views/eval.clj
@@ -1,16 +1,16 @@
(ns tryclojure.views.eval
(:use [noir.core :only [defpage]]
- [noir.response :only [json]]
- [tryclojure.models.eval :only [eval-request]]))
+ [tryclojure.models.eval :only [eval-request]])
+ (:require [noir.response :as resp]))
(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 "(" % ")") %)))
+ (let [{:keys [expr result error message] :as res} (eval-request expr)
+ data (if error
+ res
+ (let [[out res] result]
+ {:expr (pr-str expr)
+ :result (str out (pr-str res))}))]
+
+ (if jsonp
+ (resp/jsonp jsonp data)
+ (resp/json data))))

0 comments on commit 8e132f0

Please sign in to comment.