Hey guys, i've been trying to understand ring-clojure lib. I was reading the through the examples and ran into the form parameters one. (defn page [name] (str "<html><body>" (if name (str "Nice to meet you, " name "!") (str "<form>" "Name: <input name='name' type='text'>" "<input type='submit'>" "</form>" "</body></html>")))) (defn handler [{{name "name"} :params}] (-> (response (page name)) (content-type "text/html"))) (def app (-> handler wrap-params)) (run-jetty app {:port 8080}) Im guessing this is mostly a clojure itself question opposed to a ring one, but I dont really know what [{{name "name"} :params}] is doing. Could anyone explain? Thanks in advance!!
@santosx99xx that's associative destructuring, which you can read about here https://clojure.org/guides/destructuring
in this case you're having a map passed in, which will have a value under the :params
key, which itself will be a map with a value under the "name"
key, which is being bound to name
Thank you, ill read into it some more.
happy to help. if you run into more questions with destructuring pop a question in #beginners, there'll be more people responding there