Skip to content
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

query param binding for Regex route #108

Open
jngbng opened this issue Jan 27, 2020 · 0 comments
Open

query param binding for Regex route #108

jngbng opened this issue Jan 27, 2020 · 0 comments

Comments

@jngbng
Copy link

jngbng commented Jan 27, 2020

Following example in README does not work due to compilation failure.

(defroute #"/users/(\d+)" [id {:keys [query-params]}]
  (js/console.log (str "User: " id))
  (js/console.log (pr-str query-params)))

Compilation bug happens at the following line, which is actually dead code.

{:keys destruct}

I guess you already know this problem as you have used a workaround in the following test code:

https://github.com/clj-commons/secretary/blob/master/test/secretary/test/core.cljs#L162

Before the bug is resolved, the README would better be modified.

(defroute #"/users/(\d+)" [id q]
  (js/console.log (str "User: " id))
  (js/console.log (pr-str (:query-params q)))

;;; or

(defroute #"/users/(\d+)" {:as params}
  (let [[id {:keys [query-params]}] params]
    (js/console.log (str "User: " id))
    (js/console.log (pr-str query-params))))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant