Closed itaisanders closed 8 years ago
I allowed myself to tweak a quick fix for my issue about the same-key parameters. I tested it on our own code and everything seems to work fine. I tried to retain the backwards compatibility so the change will not conflict with any code using this library, just in case you decide to accept it into the core branch. I can testify that this version ran on our old code without any problem or external fix.
one more thing: I fixed the tests so there is no error, but I didn't run these tests myself, only our own tests of the code using the library.
again - tested on our code and works fine with no external changes.
Of course you're right that there should be support for multi-value parameters. But with the given API there is still a problem handling this edge case. Until now, setting and overwriting a parameter by calling req.param("x", 1)
and then req.param("x", 2)
overwrites the value. It's also stated in the docs that one can overwrite existing parameter values. So changing the current interface semantics is not the best option.
Options how this could be solved:
enableMultiValuedParams(true)
(default: false) or multiValues()
and only then change semantics of req.param()
.Collection
and []
as param value in req.param(name, value)
Thanks for your contribution, but I've implemented in a way it remains compatible with old code.
You can now either call request.multipleValues()
and then multiple times param(name, value)
or just request.param("name", Arrays.asList("orange", "apple", "banana"))
I hope this helps. If not, you can always use your own fork/branch - it's MIT licensed.
changed Request.params to hold a list of pairs instead of a map to allow multiple occurrences of the same parameter key with different values.