Fork me on GitHub
#clojure
<
2016-04-30
>
leontalbot00:04:24

Hi! I'd like to encode nested-map to url params

leontalbot00:04:46

{:amount "2000"
 :metadata {:order-id "132ad31"
            :s-tracking "93814938"}}

leontalbot00:04:59

"amount=2000&metadata[order_id]=132ad31&metadata[s_tracking]=93814938"

leontalbot00:04:21

Is there something out-of-the-box I can use?

leontalbot00:04:55

apparently [ring.util.codec :refer [form-encode]] can't do exactly this...

leontalbot00:04:41

Ok, this does the trick...

leontalbot00:04:49

(defn create-charge [body]
  (client/post ""
               {:query-params body
                :headers {:Authorization (str "Bearer " sk-token)}
                :as :x-www-form-urlencoded
                :accept :json
                :throw-exceptions false
                }))

tom01:04:04

What do people like to use these days for building a REST API?

thug.nasty01:04:15

compojure, I beliebe

thiagofm10:04:18

I'm currently using midje, and my tests usually end up as shown in the example below:

thiagofm10:04:20

(fact "default value is returned for empty sequences" (first-element [] :default) => :default (first-element '() :default) => :default (first-element nil :default) => :default (first-element (filter even? [1 3 5]) :default) => :default))

thiagofm10:04:01

Generally, I'm testing inside a fact, the same function. I wish I could dry up this and instead just specify the arguments => output.

thiagofm10:04:05

Any recommendations?

lewix12:04:58

I get an error message when I type in (get-messages) in the repl

IllegalArgumentException db-spec mount.core.DerefableState@c1b586e is missing a required parameter  clojure.java.jdbc/get-connection (jdbc.clj:292).
` https://github.com/6ewis/guestbook/blob/master/resources/sql/queries.sql

curtis.summers12:04:12

@lewix: you need to reference the database namespace. Read through: http://clojurians-log.mantike.pro/luminus/2016-03-11.html

curtis.summers12:04:26

Something like (use 'guestbook.db.core)

lewix12:04:48

curtissummers: I'm not sure what happened but restarting the repl worked

lewix12:04:53

(restart)

nkraft13:04:04

@seancorfield: Thanks for the examples, but that's not quite the issue I'm having. My problem is that my CSS/JS files are not being found. I've written them the same way you have, but mine are not loaded, though they are in the classpath. In Python and Django, I remember setting up a staticfiles variable that specified the location of these files. Is there something similar for Selmer, or another reason perhaps it can't find my files?

seancorfield16:04:56

@nkraft: that doesn't sound like a Selmer issue since that just transforms HTML. It's about how your http server is running and what the URLs to those files would be.

seancorfield16:04:20

@nkraft: are you using Ring middleware to serve up resources, for example?

kevinmershon16:04:07

Does anyone know if there's any published data or surveys of who is using clojure, by location and by industry?

devn16:04:06

I think the annual Clojure survey may have included industry info

devn16:04:12

But not regional usage

kevinmershon16:04:16

@devn Thanks. I just read the 2015 one. Not exactly by industry, as it lumped all web development together, but it was helpful nonetheless

devn20:04:26

@kevinmershon: regional usage can be understood through looking at active meetup groups to some extent, I imagine

devn20:04:56

It would be interesting to see more precise info though