Fork me on GitHub
quan xing06:01:05

I saw the compojure wiki In Middleware chapter.

(defn wrap-current-user [handler database]
  (fn [request]
    (let [user-id (-> request :session :user-id)
          user    (get-user-by-id database user-id]
      (handler (assoc request :user user)))))
To solve this problem, we can use wrap-routes:
(-> (context "/user" {:keys [user]}
      (GET  "/current" ...)
      (POST "/current" ...))
    (wrap-routes wrap-current-user))
the wrap-current-user has two parameters that handler and database. the wrap-current-user function is called by wrap-routes, the 'database' argument is how to pass to the wrap-current-user

Arnav G12:01:06

What's the different between `::keyword` and `:keyword`?

 (fn [_ _]
 (fn [_ _]


I'd try it like Alex suggests but :keyword is an un-namespace keyword whereas ::keyword is shorthand for :current-namespace/keyword


P.S. the `::` shorthand is useful for referencing keywords that are namespaced in a namespace you require into your current namespace. For example,

(ns my-current-ns
  (require [my.longer.nested.other-ns :as other]))

(def foo [m x]
  (assoc m ::other/key-from-other x))


In the example above ::other/key-from-other expands to :my.longer.nested.other-ns/key-from-other

Arnav G14:01:24

Got it! Thank you 🙂


I am trying to add space before capital letters in string like this "HelloWorld, ThankYou" in clojurescript by using clojure.string/replace "HelloWorld, ThankYou" #"(\p{Ll})(\p{Lu})" "$1 $2" but it is not working.


I don’t usually use POSIX character classes, but from looking at the docs (, I get the impression you have to spell them out, e.g. \p{Lower} etc.


Thanks, the lower one worked, and what to do if I want to reverse it like remove space?


I would just use either a literal space or the \s whitespace wildcard.


(let [s "This line   has  too        many      spaces."]
  (clojure.string/replace s #" +" " "))
=> "This line has too many spaces."



(let [s "This line   has  too        many      spaces."]
  (clojure.string/replace s #"\s+" " "))
=> "This line has too many spaces."


Sorry, not space if I have an underscore between, and I need to replace it with space "TT_Hello_World, CC_Thank_You" but only need to replace combination of [a-z][_][A-Z]


Sure, just use literal underscore.

(let [line "TT_Hello_World, CC_Thank_You"]
  (clojure.string/replace line #"([a-z])_([A-Z])" "$1 $2"))
=> "TT_Hello World, CC_Thank You"


Thanks, It worked

👍 1

(clojure.string/replace "HelloWorld, ThankYou" 
                        #"(\p{Lower})(\p{Upper})" "$1 $2")
=> "Hello World, Thank You"


Personally I’d just use #"([a-z])([A-Z])"

David Pham17:01:42

May I ask if will be published on maven/Clojure at some points?? Because of corporate policy we can’t pull deps from GitHub/gitlab?


Does your company not allow open-source software to be used?

David Pham20:01:15

I can’t pull any repository from GitHub.

David Pham20:01:14

It is a bit incoherent since I could pull any docker images from docker hub and some others. So I could probably pull an image where Clojure Tools is included and search for the jar xD


Such a dumb policy 😞

🎉 1
David Pham21:01:54

Better be safe than sorry, I work in a old industry with life threatening consequences on data leaks.

👀 1
Alex Miller (Clojure team)18:01:11

You could build it yourself too :)

David Pham18:01:34

It would bring me outside of my comfort zone :)

David Pham18:01:12

I guess I have been spoiled by tools.deps and everyone's work for too long :)

Alex Miller (Clojure team)18:01:47

It's just jarring the source dir :)

Alex Miller (Clojure team)18:01:35

I guess you'd need a pom too, but it's a few lines of :)

Alex Miller (Clojure team)18:01:20

(I know, I know, you don't have

🙃 1
David Pham18:01:50

I guess depstar would also work xD.

David Pham18:01:31

Thanks a lot for all your work, if you make a Clojure Survey this year, you could ask if people want to have a official tools to be published in Clojure/maven if this is okay to have everything on GitHub xD (my corporate me would tell it makes things easier to have code in Clojure xD).

Alex Miller (Clojure team)18:01:37

I will probably get around to doing it, have just been waiting to see if demand


FYI @neo2551 depstar is deprecated


☝️:skin-tone-2: Yeah, I'd be surprised if a company that doesn't allow you to download software from GitHub would allow you to use a deprecated and archived open source project?


does the jar include the repo information? If not there’s no way to catch that with an automated policy right?


Hey all, Is there a nicer pattern for

(if true (do-some-update x) x)
I guess cond->? (cond-> x true (do-some update))


(cond-> x (condition) (do-some-udpate) is a pattern i use often


yeah 🙂


but sometimes there’s nothing wrong with (if (condition) (f x) x)