Closed bobby closed 8 years ago
Hi @bobby,
Thanks for reporting this. The first behaviour is due to pedestal not including a :query-params
key when there are no query parameters. I think in this case nil has the same semantics as an empty map, so I have made a change in pedestal-api
to merge empty maps of parameters in the common-body
interceptor so that your use case works. This is now available in 0.2.0-SNAPSHOT.
The second behaviour is due to pedestal's query string parsing, you might want to raise an issue with them about that.
io.pedestal.http.route> (parse-query-string "abc=123&def")
;; => {:abc "123", nil "def"}
The third behaviour is due to schema's coercion of booleans. You can pass in your own coercions to the coerce-request
interceptor to change this behaviour.
Hope this helps!
Thanks for the thorough response! I'll have a look at 0.2.0-SNAPSHOT
When decorating a handler with
I would expect to be able to omit the query parameter
bar
. However, currently I get the following HTTP400
when omittingbar
:Also of note (both of which seem wrong, though less important):
I would expect to be able to pass the key
bar
with no value, and see{:bar true}
in query params, sincebar
is declared as as/Bool
.Also
Returns
200
with{:bar false}
, as one might expect.This next one was more surprising:
Returns
200
with{:bar false}
. This seems at odds with Clojure's own truthiness semantics, where everything other thannil
andfalse
evaluate logicaltrue
. So common conventions like?bar=1
,?bar=present
, etc. get coerced to{:bar false}
, which seems wrong. I'd expect the opposite, where?bar=false
and perhaps?bar=
evaluate to{:bar false}
, and anything else evaluate to{:bar true}
. Thoughts?