gpt4 book ai didi

clojure - java.lang.String 无法转换为 clojure.lang.IFn

转载 作者:行者123 更新时间:2023-12-01 12:33:11 25 4
gpt4 key购买 nike

我只是想设置名为 test 的 cookie 的值。

example: http://www.luminusweb.net/docs/sessions_cookies.md

我的代码:

    (GET "/new-location" req (new-location req)
(-> "cookie set" response (update-in [:cookies "test" :value] "Alice")))

错误:

java.lang.String cannot be cast to clojure.lang.IFn

如果您想查看新位置功能:

(defn new-location [resp]
(render "{{resp}}" {:resp resp}))

响应输出:

{:ssl-client-cert nil, :cookies {"test" {:value "5Zn5Z6shY7vJFH3dYyhmDzfB/MmLkZVShKxxrNXop7QgubGBLBGQMzsdPX3c9kJkc/H3oFns/Y3+yU5RNXmBCp+Hs5ha0mEMhiRcGw04Z4w=--BZCShBKs13BCNkVGtyKAtuOMqPCH+sFl3t39qnM6Eks="}}, :remote-addr "127.0.0.1", :params {}, :flash nil, :handler-type :undertow, :route-params {}, :headers {"host" "localhost:3000", "user-agent" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/45.0.2454.15 Safari/537.36", "cookie" "test=5Zn5Z6shY7vJFH3dYyhmDzfB%2FMmLkZVShKxxrNXop7QgubGBLBGQMzsdPX3c9kJkc%2FH3oFns%2FY3%2ByU5RNXmBCp%2BHs5ha0mEMhiRcGw04Z4w%3D--BZCShBKs13BCNkVGtyKAtuOMqPCH%2BsFl3t39qnM6Eks%3D", "connection" "keep-alive", "upgrade-insecure-requests" "1", "accept" "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8", "accept-language" "en-GB,en-US;q=0.8,en;q=0.6", "accept-encoding" "gzip, deflate, sdch", "dnt" "1", "cache-control" "max-age=0"}, :server-port 3000, :content-length -1, :form-params {}, :compojure/route [:get "/new-location"], :session/key "5Zn5Z6shY7vJFH3dYyhmDzfB/MmLkZVShKxxrNXop7QgubGBLBGQMzsdPX3c9kJkc/H3oFns/Y3+yU5RNXmBCp+Hs5ha0mEMhiRcGw04Z4w=--BZCShBKs13BCNkVGtyKAtuOMqPCH+sFl3t39qnM6Eks=", :server-exchange #object[io.undertow.server.HttpServerExchange 0x2035c15c "HttpServerExchange{ GET /new-location}"], :query-params {}, :content-type nil, :path-info "/new-location", :character-encoding nil, :context "", :uri "/new-location", :server-name "localhost", :query-string "", :body #object[io.undertow.io.UndertowInputStream 0x2ef23b2a "io.undertow.io.UndertowInputStream@2ef23b2a"], :multipart-params {}, :scheme :http, :request-method :get, :session {:ring.middleware.session-timeout/idle-timeout 1438182648}}

最佳答案

update-in采用提供新值的函数,而不是新值 - do

(update-in [:cookies "test" :value] (constantly "Alice"))

相反。

关于clojure - java.lang.String 无法转换为 clojure.lang.IFn,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31702233/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com