This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2017-04-25
Channels
- # aleph (6)
- # beginners (6)
- # boot (94)
- # cider (34)
- # cljs-dev (36)
- # cljsrn (12)
- # clojure (124)
- # clojure-dev (41)
- # clojure-dusseldorf (6)
- # clojure-italy (3)
- # clojure-norway (1)
- # clojure-russia (161)
- # clojure-sg (7)
- # clojure-spec (71)
- # clojure-uk (95)
- # clojurescript (38)
- # core-async (16)
- # cursive (14)
- # data-science (1)
- # datascript (12)
- # datomic (15)
- # emacs (22)
- # funcool (2)
- # hoplon (15)
- # jobs-rus (2)
- # juxt (9)
- # liberator (7)
- # lumo (1)
- # off-topic (136)
- # onyx (24)
- # pedestal (39)
- # perun (2)
- # planck (20)
- # re-frame (23)
- # spacemacs (31)
- # unrepl (5)
- # untangled (1)
- # vim (1)
- # yada (29)
How do I set a cookie from Yada? I can do it with ring.middleware.cookies, but that feels like cheating
If I take the response from the context and assoc into the :cookies
entry, it doesn’t work out the way I want
@borkdude https://github.com/juxt/yada/blob/master/test/yada/create_response_test.clj
(merge (:response ctx)
(redirect (-> ctx :parameters :query :response))
{:cookies {"session" {:value "" :expires 0}}})
Something like this you mean?Ah good, thanks for the example. What does it mean in the docs where it says in the manual: > When you need complete control over the response you should return the request-context’s response, modified if necessary. In which case yada will see that you want to be explicit and get out of your way. I thought this meant that Yada won’t touch your response any more, like a raw Ring response
Good question. One I must defer to @malcolmsparks 🙂
Ah, if I include this key :max-age 0
then it won’t send the header at all… that was tricky
https://github.com/ring-clojure/ring/wiki/Cookies I think yada is just using this
Gotcha:
(yada.cookies/cookies-coercer {"test" {:value "Foo"
:domain "foo"
:max-age 0}})
;;=> {:error {"test" {:max-age (not (instance? java.lang.String 0))}}}
This failed silently on me, I think I should have seen a warning@dominicm This doesn’t depend on Ring middleware: https://github.com/juxt/yada/blob/master/src/yada/cookies.clj
@dominicm That’s not my point. You said “I think Yada is just using this cookies built into ring”. I thought you meant it used logic from Ring. It reimplements that cookie coercion (maps to strings) from Ring, but it doesn’t use the middleware directly.