ring-swagger

ring-swagger & compojure-api
adc17 2018-04-18T03:11:33.000118Z

I’ve been reading through the following page from the compojure-api wiki, and I’m confused by a few things. https://github.com/metosin/compojure-api/wiki/Creating-your-own-metadata-handlers 1. What are let/letk bindings, and what is the difference between them? I can’t find an explanation anywhere in the wiki. 2. How is the vector passed into :let/:letk/:middleware/etc. used by compojure-api? I know that it’s probably going to be macro-expanded, but beyond that it’s unclear how the arg is processed. 3. Why in the example is the _ arg re-used in the method body? Isn’t _ a convention for when an arg is unnecessary? I suspect that once I understand let/letk bindings better, this will all become clearer, but answers to any of the above would be appreciated.

miikka 2018-04-18T07:13:57.000202Z

1. letk/fnk/defnk bindings is explained here: https://github.com/plumatic/plumbing/tree/master/src/plumbing/fnk (it talks only about defnk, but letk uses the same syntax)

miikka 2018-04-18T07:14:02.000296Z

(don't know about 2/3)

adc17 2018-04-18T15:21:57.000020Z

@miikka in that link, defnk is a way of assigning args to vars in a function by passing them as :var arg. But that’s pretty much already how let bindings function…“let left-val equal right-val”. So what’s the difference in the context of a let binding?

miikka 2018-04-18T15:38:54.000723Z

The destructuring syntax is different from the standard one

adc17 2018-04-18T16:28:25.000165Z

Ok, I was confused by the use of function definitions. So instead of (let [{:keys [foo]} foo-map]) with a letk binding you could just do (let [foo foo-map]).