This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2019-09-20
Channels
- # announcements (5)
- # beginners (37)
- # calva (3)
- # cider (23)
- # clojure (98)
- # clojure-dev (16)
- # clojure-europe (5)
- # clojure-italy (4)
- # clojure-nl (5)
- # clojure-spec (7)
- # clojure-uk (52)
- # clojurescript (14)
- # cursive (15)
- # data-science (1)
- # datomic (20)
- # emacs (7)
- # flambo (2)
- # fulcro (10)
- # jackdaw (1)
- # jobs (3)
- # joker (2)
- # juxt (3)
- # keechma (3)
- # leiningen (8)
- # luminus (3)
- # music (1)
- # off-topic (83)
- # pathom (19)
- # re-frame (19)
- # reitit (4)
- # shadow-cljs (76)
- # spacemacs (95)
- # tools-deps (16)
what do you all use to send e-mail from your application?
I used postal years ago but it seems to no longer be developed
If it still works, does it need to be changed? (I do not know if it still works)
um. i think it works actually
If the underlying language and libraries it relies upon value backwards compatibility, and the things it interoperates with, then changes are needed less often.
sweeps typos under rug
What is the idiomatic way to reject a function call if parameters do not meet the expectations? Let's say a function only works in non-empty lists, and I call that function with an empty list.
Does it need to be specified with spec
?
No, you can use preconditions like {:pre [(some-predicate? my-arg1)...]}
you can spec it with fdef
, e.g. by saying that its input should be a (s/coll-of something? :min-count 1)
Good Morning everybody. I decied to do a webapp from ground up. But the documentation... it is so fragmented, everybody is using different libraries, a lot of things are deprecated etc... Can somebody help me here? I would love to use sse-consumer as SSE which updates my HTML generated by HICCUP (function (html-layout/driver-monitoring-country "Driver Monitoring" country-selection)) renders HTML. I know that there is async abstraction in http-kit but it looks different than "native" async that i would like to use as I already implemented one part in it. So if i can stay with ring + compojure + async it would be great. This is my async block - when I get driver-status, something is saved to the database and sse-consumer writes out message.
(defn sse-consumer
"Accept messages and persist them to a database."
[]
(fn [req res raise]
(let [in (chan (sliding-buffer 64))]
(go-loop [data (<! in)]
(when data
(do
(println (format "sse-consumer received message %s" data))
(recur (<! in)))))
in)))
(defn database-consumer
"Accept messages and persist them to a database."
[]
(let [in (chan (sliding-buffer 64))]
(go-loop [data (<! in)]
(when data
(do
(save-driver-status)
(recur (<! in)))))
in))
(defn producer
"Produce messages and deliver them to consumers."
[& channels]
(go
(doseq [msg (get-driver-status)
out channels]
(<! (timeout 300000))
(>! out msg))))
(xbim.driver-data/producer (xbim.driver-data/database-consumer) (xbim.driver-data/sse-consumer))
These are my routers
(defroutes route-map
(GET "/driver-monitoring" {cookies :cookies}
(html-layout/driver-monitoring-general "Driver Monitoring" cookies))
(GET "/driver-monitoring/custom" [country-selection]
(do (println country-selection)
(html-layout/driver-monitoring-country "Driver Monitoring" country-selection)))
(route/not-found "<h3>Route Not defined!</h3>"))
These are my wrappers
(def app
(-> route-map
(wrap-resource "public")
(wrap-file-info)
(ring.middleware.session/wrap-session)
(wrap-cookies)
(compojure.handler/site)))
Thank you very much.https://www.lucagrulla.com/posts/server-sent-events-with-ring-and-compojure/ This tutorials leads just to...
Fri Sep 20 08:59:01 CEST 2019 [worker-3] ERROR - GET /async
clojure.lang.ArityException: Wrong number of args (1) passed to: xbim.core/fn--18358/fn--18359
at clojure.lang.AFn.throwArity(AFn.java:429)
@UBRV1HXPD I’m running into the same issue, did you ever figure out how to do this?
you can spec it with fdef
, e.g. by saying that its input should be a (s/coll-of something? :min-count 1)
(uh did I send doubly? flaky internet)
hahaha, yes. But thank you. I'll check that out.
Hi again.
I just finished writing the spec for one function my-function
inside namespace
.
I also created a test-my-namespace.clj
inside test
.
Then, I was able to call (stest/check
my-function)`, and I got this output:
;; => ({:spec #<clojure.spec.alpha$fspec_impl$reify__2451@5cdab40c>,
;; :sym namespace.line/my-function,
;; :clojure.spec.test.check/ret {:num-tests 1000, :pass? true, :result true, :seed 1568968371375, :time-elapsed-ms 5851}})
But now I'd like to know how to set those generated tests, so they run when I run lein test
from the terminal.
In the same way a test defined with deftest
would have run.
I've read the guide on spec and haven't found it yet. In the guide, it lists the different ways to build the generators. And the third one says >Use test.check or other test.check compatible libraries (like test.chuck) https://clojure.org/guides/spec#_custom_generators
I don't know if that's what I'm looking for. Specially since it's the least preferred.
@davidomarfch check https://ask.clojure.org/index.php/8590/clojure-spec-alpha-check-inside-clojure-testing-framework
Also https://github.com/gfredericks/test.chuck/blob/master/README.md#alternate-clojuretest-integration may be helpful
Wow. Just checked the first one. Very creative. I think I'll stick with that one. Thanks!
im having a really hard time getting a CORS middleware to return 200 on options requests, and was hoping someone might help walk me through it
now with line number! (https://gist.github.com/patientplatypus/0e3defaf1cfeff3b6ca3f0910993ce10#file-gistfile1-txt-L86)
Hi! I'm having a problem doing a redirection with Ring. If I'm on a page with the POST method, doing the redirection will keep it. How can I force all my redirections to be GET? Thank you in advance.
does anyone have any idea why this wont pass cors? i have been at this for hours and hours and hours https://gist.github.com/patientplatypus/810e8719a3c3905c3c2f04b966a3c624 this shouldnt be this hard!
https://stackoverflow.com/questions/58030830/clojure-cross-origin-error-totally-lost
@pweyand What's with the preflight stuff in that code? You should just be able to use wrap-cors
but it needs to be the outermost layer of middleware, e.g.,
(-> handler
(main-middleware)
(wrap-cors ,,, various CORS options here))
Here's what we have at work:
(-> handler
,,, other middleware ,,,
(ring-cors/wrap-cors
:access-control-allow-headers #{"accept"
"accept-encoding"
"accept-language"
"authorization"
"content-type"
"origin"}
:access-control-allow-methods [:delete :get
:patch :post :put]
;; 24 hours (in seconds) -- note that only Firefox
;; will honor this; other browsers cap lower!
:access-control-max-age "86400"
:access-control-allow-origin #".*"))
wrap-cors
handles the preflight check internally.