Clojure 响应映射为零
我什么都不懂。 当我执行Clojure 响应映射为零,clojure,compojure,ring,Clojure,Compojure,Ring,我什么都不懂。 当我执行curl-xget--header'Accept:application/json'http://localhost:3000/api/hello“我大摇大摆地得到了一个很好的答案{“结果”:1}。 但是,当我尝试类似于:http://localhost:3000/api/hello?criteria=drf,服务器给我java.lang.NullPointerException:响应映射为nil。我很确定它不是零,因为我仍然可以在屏幕上看到我的{“result”:1}。
curl-xget--header'Accept:application/json'http://localhost:3000/api/hello“
我大摇大摆地得到了一个很好的答案{“结果”:1}
。
但是,当我尝试类似于:http://localhost:3000/api/hello?criteria=drf
,服务器给我java.lang.NullPointerException:响应映射为nil
。我很确定它不是零,因为我仍然可以在屏幕上看到我的{“result”:1}
。
但是在第一个错误之后,每个GET/hello
请求(没有任何查询参数)都会在服务器端给出一个错误,同时仍然向客户端给出正确的答案
我需要重新启动服务器以使错误停止。在第一个带有查询参数的请求出现之前,它一直有效
(ns swag.handler
(:require [compojure.api.sweet :refer :all]
[ring.util.http-response :refer :all]
[clojure.java.jdbc :as j]
[clojure.core.match :as match]
[clojure.spec.alpha :s s]
)
(def app
(api
{:swagger
{:ui "/"
:spec "/swagger.json"
:data {:info {:title "Trash"
:description "Compojure Api example"}
:tags [{:name "api", :description "some apis"}]}}}
(context "/api" []
:tags ["api"]
(GET "/plus" []
:return {:result Long}
:query-params [x :- Long, y :- Long]
:summary "adds two numbers together"
(ok {:result (+ x y)}))
(GET "/hello" []
:query-params [& z]
(let [criteria (:criteria z) values (:date z)]
(println z)
(ok {:result 1})))
))
)
我们面临的问题是,我们需要在出现此错误的端点上跟踪
/s
(在调试时查看您的q,但刚刚解决)。如果您收到此消息,请在浏览器中检查favicon.ico请求
这可能会触发响应映射为空,因为没有配置任何路由来处理它。为“/hello?”添加GET不会解决此问题吗?服务器似乎已崩溃,因此变得无响应,但浏览器仍在通过其缓存进行响应。我无法在compojure api示例中使用您的def重现此错误:。带参数的Get有效。此问题已存在3年。。我也放弃了clojure,因为un debuggableI添加了供将来参考的内容,因为我刚刚遇到了相同的问题:)