compojure.handler behavior for redundant parameters

55 views
Skip to first unread message

Chris Dale

unread,
Dec 17, 2013, 7:01:50 PM12/17/13
to comp...@googlegroups.com
Hello!

I thought I had read some place that compojure.handler's default behavior for a param string of the type ?foo=1&bar=2&foo=3 was to produce a map of the form {:foo [1 3] :bar 2}; however, I'm getting one of the form {:foo 3 :bar 2}. Was I misinformed? Has the code changed? Am I missing a configuration of some kind? Is this easy to enable, or am I to delve into the murky depths of implementing my own handler?

Thanks!

James Reeves

unread,
Dec 17, 2013, 7:08:20 PM12/17/13
to Compojure
You likely have wrap-nested-params around your handler, which assumes a Rails-like syntax of "foo[]" for building nested maps and arrays.

However, Ring 1.2.2 will include a fix to ensure that wrap-nested-params won't affect keys without square brackets, so when that is released it will act as you expect.

- James


--
You received this message because you are subscribed to the Google Groups "Compojure" group.
To unsubscribe from this group and stop receiving emails from it, send an email to compojure+...@googlegroups.com.
To post to this group, send email to comp...@googlegroups.com.
Visit this group at http://groups.google.com/group/compojure.
For more options, visit https://groups.google.com/groups/opt_out.

Chris Dale

unread,
Dec 17, 2013, 7:26:30 PM12/17/13
to comp...@googlegroups.com, ja...@booleanknot.com
Thanks you very much! Not to sound impatient, but when might that happen? Is this something where I can focus on other aspects of the site until this drops?

James Reeves

unread,
Dec 17, 2013, 7:44:29 PM12/17/13
to Compojure
You can remove wrap-nested-params if you don't need it - which you don't if you're using "foo" and not "foo[]". I believe it's included in compojure.handler/site, but this is merely a convenience function. You can apply the middleware manually for finer control.

Ring 1.2.2 will likely be out at the end of this year, or at the beginning of 2014.

- James

Chris Dale

unread,
Dec 17, 2013, 10:45:40 PM12/17/13
to comp...@googlegroups.com, ja...@booleanknot.com
Thanks again! I love the process of coming to understand how to use the software you're working with, instead of relying upon an exposed API.

Chris Dale

unread,
Dec 29, 2013, 1:56:34 PM12/29/13
to comp...@googlegroups.com, ja...@booleanknot.com
Well, it looks like I'm going to do it the foo[] way after all, and it is not entirely clear to me how to set that up, nor indeed do I know what to call it to look for it. Is this a job for cljs/js?

That is to say, are you saying the syntax it expects is foo=[bar,baz]?


On Tuesday, December 17, 2013 6:08:20 PM UTC-6, James Reeves wrote:

James Reeves

unread,
Dec 29, 2013, 3:13:45 PM12/29/13
to Compojure
On 29 December 2013 18:56, Chris Dale <adventureon...@gmail.com> wrote:
Well, it looks like I'm going to do it the foo[] way after all, and it is not entirely clear to me how to set that up, nor indeed do I know what to call it to look for it. Is this a job for cljs/js?

That is to say, are you saying the syntax it expects is foo=[bar,baz]?

You don't need to use wrap-nested-params if you don't want to. You only need it if you want Rails-like nested parameters. If you don't know what that is, chances are that you don't need it :)

Instead of using compojure.handler/site, apply the middleware you want manually to your application.

- James
Reply all
Reply to author
Forward
0 new messages