Clojure - 环流响应

时间:2017-03-01 16:34:31

标签: clojure compojure ring compojure-api

我收到一个响铃响应,我不知道如何处理。

我将一个参数传递给我的ajax POST,当它在我的compojure路径中找到函数时,而不是我传入的原始参数,我得到一个响铃响应

{:remote-addr 0:0:0:0:0:0:0:1, :params nil, :route-params nil, :headers {origin http://localhost:3300, host localhost:3300, user-agent Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Ubuntu Chromium/55.0.2883.87 Chrome/55.0.2883.87 Safari/537.36, content-type application/transit+json, content-length 42, referer http://localhost:3300/view, connection keep-alive, accept application/transit+json, application/transit+transit, application/json, text/plain, text/html, */*, accept-language en-GB,en-US;q=0.8,en;q=0.6, accept-encoding gzip, deflate, br}, :server-port 3300, :keep-alive? true, :uri /add-user!, :server-name ip6-localhost, :query-string nil, :body << stream: {:pending-puts 0, :drained? false, :buffer-size 42, :permanent? false, :type netty, :sink? true, :closed? true, :pending-takes 0, :buffer-capacity 16384, :connection {:local-address ip6-localhost/0:0:0:0:0:0:0:1:3300, :remote-address /0:0:0:0:0:0:0:1:34448, :writable? true, :readable? true, :closed? false, :direction :inbound}, :source? true} >>, :scheme :http, :request-method :post}

为什么会这样?

身体(我认为我的参数所在的地方)是

<< stream: {:pending-puts 0, :drained? false, :buffer-size 30, :permanent? false, :type netty, :sink? true, :closed? true, :pending-takes 0, :buffer-capacity 16384, :connection {:local-address ip6-localhost/0:0:0:0:0:0:0:1:3300, :remote-address /0:0:0:0:0:0:0:1:34580, :writable? true, :readable? true, :closed? false, :direction :inbound}, :source? true} >>

如何处理此问题以获取参数?

我的参数应采用{:id id :pass pass}

的形式

由于

1 个答案:

答案 0 :(得分:0)

在定义应用程序处理程序时从(wrap-params)添加ring.middleware.params中间件可能会有所帮助。

它应该会生成一个可访问的:params字段,您可以在请求处理程序中使用该字段。