我只是想设置名为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}))
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}}
答案 0 :(得分:4)