On 4 December 2013 14:04, James Laver <james.la...@gmail.com> wrote:

>
> I’m pretty sure that’s the behaviour I was already seeing. Imagine this
> scenario:
> - I access this route passing in the ID of the database record I wish to
> modify
> - I pass in a new value for it in the post data (okay, bad example, you’re
> not likely to want to change an integer primary key, but bear with me)
> - I then need access to not only the value of the id from the params but
> also the value from the post data, separately
> - :form-params uses string keys not keywords so it then needs to be
> keywordified before it’s suitable for passing to the database layer (not to
> mention to make it significantly less of a pain to work with in userland
> code)
>

Surely that's only a problem if you choose names for your route parameters
that conflict with your form parameters?



> I think it’s mostly the effect of trying to use all of the pieces together
> that’s causing me some pain. I’ve now worked around it with the middleware
> I previously posted, but it was a little surprising that I had to.
>
> Would you mind please explaining:
> a: how that syntax deals with merges? I don’t quite understand what’s
> going on underneath. Does that actually bind to params?
> b: how i could get those params extracted into a variable as well as
> access to the request map?


The code sample demonstrates using normal Clojure destructuring with
Compojure's more specialised kind. I wasn't merging anything, I was just
pulling out the form parameters and a parameter named "id".

This is covered in more detail in the Compojure wiki:

https://github.com/weavejester/compojure/wiki/Destructuring-Syntax

- James

-- 
-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to