Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Use jsonp from noir.response.

  • Loading branch information...
commit 8e132f046391b1c5fb2a383154f02ccf2f4a35ad 1 parent 006cb69
@Raynes authored
Showing with 12 additions and 12 deletions.
  1. +12 −12 src/tryclojure/views/eval.clj
View
24 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))))
Please sign in to comment.
Something went wrong with that request. Please try again.