我确定我一定做错了什么......这是clojure的相关行:
(ns command.command-server
(:use [org.httpkit.server :only [run-server]])
(:use [storage.core-storage])
(:use compojure.core)
(:use [command.event-loop :only [enqueue]])
(:require [compojure.handler :as handler]
[compojure.route :as route]
[ring.middleware.json :as middleware]))
(def app
(-> (handler/api app-routes)
(middleware/wrap-json-body)
(middleware/wrap-json-response)
(middleware/wrap-json-params)))
;in app-routes, the rest left out for brevity
(POST "/request" {json :params}
(do
(queue-request json)
(response {:status 200})
))
(defn queue-request [evt]
(let [new-evt (assoc evt :type (keyword (:type evt)))]
(println (str (type (:val1 evt))))
(enqueue new-evt)))
当我从 jquery 发送以下内容时,末尾附近的“println”将 :val1 的类型显示为 java.lang.String:
$.ajax({
type: "POST",
url: 'http://localhost:9090/request',
data: {type: 'add-request', val1: 12, val2: 50},
success: function(data){
console.log(data);
}
});
那么我做错了什么?