Java.lang.String cannot be translated to clojure.lang.IFn

I'm just trying to set a cookie named test.

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

      

My code:

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

      

Mistake:

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

      

If you want to see the new location feature:

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

      

Exit to exit:

{: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}}

      

+3


source to share


1 answer


update-in accepts a function to provide a new value, not a new value - do

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

      



instead.

+4


source







All Articles