On 4 Dec 2013, at 11:38, James Reeves <ja...@booleanknot.com> wrote:

> Compojure also adds to the :route-params key, so if you need to, you can 
> explicitly decide how you want maps of parameters to be merged. The :params 
> key is just there for the convenience of the majority of users.
> 
> You could write something like:
> 
>     (POST "/blah/:id" [id :as {params :form-params}] ...)
> 
> This would get the id from the routes (as they're always merged last), and 
> the parameters map from :form-params.

Hi James,

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)

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?

Cheers,
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