This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2019-08-04
Channels
- # announcements (2)
- # beginners (24)
- # cider (53)
- # clara (4)
- # clj-kondo (3)
- # cljdoc (2)
- # clojars (1)
- # clojure (17)
- # clojure-dev (48)
- # clojure-russia (14)
- # clojure-uk (10)
- # clojuredesign-podcast (5)
- # clojurescript (11)
- # cursive (4)
- # events (5)
- # joker (1)
- # juxt (1)
- # kaocha (1)
- # re-frame (13)
- # reagent (1)
- # reitit (2)
- # sql (28)
how can i clj-http.client/post
with :body-params
?
because docs only mention :form-params
and :query-params
.
my understanding is that :form-params
is basically :body-params
When I print request on server it includes :form-params
under :params
and :form-params
keys.
I need params under :body-params
key.
Basically I'm using day8.re-frame.http-fx
which sends :post
params under :body-params
key. So, all handlers at server extract :body-params
from request.
I want to do similar :post
requests with clj-http.client/post
, to inspect routes from REPL.
@ahmed1hsn I usually don't use a HTTP-client to test routes from REPL. If your backend is Ring compatible (which it probably is) you can call the handler function directly and pass a request map created with https://github.com/ring-clojure/ring-mock
handlers are wrapped anonymous functions inside integrant init-key
multimethod.
I don't know how can I find reference to handler to run ring-mock
I'm using duct with Ataraxy as routing lib.
But if you want to use clj-http
you should probably put the body under :body
, as in the first example at https://github.com/dakrone/clj-http#post
Thanks it works, but I have to escape double quotes with slashes.
Yes, body is expecting a string. You probably want to use a library to convert whatever data structure you have to string. For example cheshire
or jsonista
if you're using JSON for communication. If you're using EDN you can just use pr-str
.
is it useful to use pmap
in the middle of a ->>
or ->
processing pipelines? I could not create any example where the benefits of parallelization was evident.
Ex:
(->> data
(map fn-transf1)
(pmap fn-transf2)
(filter fn-business1))
pmap is useful in a pretty narrow set of circumstances. The map task (fn-transf2) really needs to be pretty coarse grained to exceed the parallelization overhead
thanks @U064X3EF3 I thought so. I faced situations where I needed to perform ETL to several clients. We implemented the code to handle 1 client and used pmap
to run for all of them later. However, even in this scenario, I'm feeling that I would like more control about the processes that are running. For example, the number of threads, backpressure and so on. Is this a valid concern? Is pmap
being applied in the a proper scenario?
pmap is good for a quick hack. For anything serious, I usually don’t want the laziness that pmap includes and I just a Java executor to get more control or a lib like claypoole
Hello! I would love a critique on this little temperature converter program if willing. https://pastebin.com/xpkCkmhU
My concerns/questions: 1) Almost all my functions have side effects, right? If a function calls another function that has side effects is that now considered also impure? How do I make this more pure? 2) How would you approach error handling? If the input isn't perfect this thing won't work. 3) How to approach looping this so you can keep inputting temps until you write "quit"? Every attempt I make hasn't worked right, I'm not sure if I'm understanding the underlying mechanics behind flush
and read-line
maybe. 4) I also need to handle negative temps so would like to see how you would take and parse user input that makes this all a bit better. Thank you!
@chase-lambert I made some changes to the code with some comments: https://gist.github.com/schmee/b6ce2ec9b49733696fd99ffecc413df1, I hope it’s useful 🙂