Search code examples
clojurekeycompojuredatomic

compojure destructuring making integers... not integers?


This Compojure GET route with hard-coded id...

   ;posts 
(GET "/post:id" [id :as request]
  ;(str "the post id is... " id)
   (def email (get-in request [:session :ze-auth-email]))
   (vb/post-page-draw email 17592186045616))

Works^

However, with symbolic id (on the last line)...

   ;posts 
(GET "/post:id" [id :as request]
  ;(str "the post id is... " id)
   (def email (get-in request [:session :ze-auth-email]))
   (vb/post-page-draw email id)

Where the url is:

localhost:4000/post17592186045616  ;;i.e. the number from above

(edit: no colon between the word post and the id)

Returns a huuuge stack trace, mainly breaking on

java.lang.Exception
processing rule: (q__7967 ?title ?content ?tags ?eid), 
message: processing clause: [?eid post/title ?title], 
message: Cannot resolve key: 17592186045616

So, I've been able to isolate it to compojure destructuring just not liking the integer I'm passing... how can I get my (vb/post-page-draw email id) to work with parameters passed via the URL?


Solution

  • Try:

    (vb/post-page-draw email (Long. id))