-
Notifications
You must be signed in to change notification settings - Fork 149
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Failed to acquire keys which have default value. #310
Comments
Hi. This is originating from Plumbing (require '[plumbing.core :refer :all])
(defnk get_messages
[{since :- s/Int nil}
{until :- s/Int nil}
{limit :- s/Int 20}
:as query-params]
query-params)
(get_messages {})
; {} |
Also related:
e.g. we could add a coercer to compojure-api, which would apply the defaults, but that still doesn't woudn't populate the (GET "/defaults" []
:query [query-params {:limit (st/default s/Int 10)}]
(prn query-params)) |
IMO: Not a bug, works the same as Clojure default map destructuring:
Default values from destructuring only work when referring the destructured value directly. |
Hi Tommi, thanks for your speedy reply and excellent solution. I've read the related links you provided. It seems need Plumbing to provide this handy notation. According to @Deraen 's opinion, maybe I went the wrong way, I'll try Cheers |
Closing this, continues on #174 |
Hi, I have simple route below
Example:
I have printed
query-params
Var at present , it seems didn't contains the keys which have default value.Results:
curl /get_messages
=> {}curl /get_messages?limit=10
=> {:limit 10}I expect :
curl /get_messages
=> {:limit 20}Or I missed some configurations, thanks for reading this post.
The text was updated successfully, but these errors were encountered: