it seems like nested destructuring doesn’t work with the context macro from compojure.api.sweet
is that by design or should i file a bug
for example:
; this works
(context "" {:keys [identity]}
...)
; this doesn't work
(context "" {{{:keys [user-id]} :user} :identity}
...)
@nickmbailey does that work with vanilla Compojure? if it does, it’s a bug in the compojure-syntax parser at compojure.api.meta
. I guess I haven’t used that deep with routes.
@jimenezsaezjoseantoni older versions of ring-swagger emitted those, should be fix in 0.24.3
: https://github.com/metosin/ring-swagger/blob/1e932951d115706e7724cedd032d623e2d849905/CHANGELOG.md#0243-24102017
Thanks, i will take a look!🙂
@ikitommi well compojure api generates a compiler error and compojure doesn’t so i’d guess a bug in compojure.api.meta then
repl session:
dev=> (require '[compojure.core :refer [GET]])
nil
dev=> (require '[compojure.api.sweet :refer [context]])
nil
dev=> (GET "/" {:keys [identity]}
#_=> (println identity))
#<Fn@2747f665 compojure.core/wrap_route_matches[fn]>
dev=> (GET "/" {{{:keys [user-id]} :user} :identity}
#_=> (println user-id))
#<Fn@11623d80 compojure.core/wrap_route_matches[fn]>
dev=> (context "" {:keys [identity]}
#_=> (println identity))
#function[clojure.core/identity]
#compojure.api.routes.Route
{:childs [nil]
:handler #<Fn@3e251ea0 compojure.core/make_context[handler]>
:info {}
:method nil
:path ""}
dev=> (context "" {{{:keys [user-id]} :user} :identity}
#_=> (println user-id))
java.lang.RuntimeException: Unable to resolve symbol: user-id in this context
clojure.lang.Compiler$CompilerException: java.lang.RuntimeException: Unable to resolve symbol: user-id in this context, compiling:(/private/var/folders/47/631bq0cs75q8gk7jf0r8c30h0000gn/T/form-init2896469317029772128.clj:2:3)
@nickmbailey I would suspect https://github.com/metosin/compojure-api/blob/master/src/compojure/api/meta.clj#L595
makes sense
i can file a bug
and possibly have some time to look at a fix later this week
that would be great!
I’m under 🌴 until 12.3. Juho & Miikka will help with any possible stuff there is.
Have a great vacation!