(clojure.java.browse/browse-url “http://clojure.org”)

While reviewing the sources of RESTful Clojure webapp skeleton w/Compojure, Ring, Enlive, and ClojureQL I found the clojure.java.browse namespace with the browse-url function I was looking for for some time.

By a complete chance I stumbled upon this function which I happily incorporated in the librarian-clojure project. The function requires a URL to be open, e.g.

$ lein repl
REPL started; server listening on localhost port 44510
user=> (clojure-version)
"1.2.1"
user=> (clojure.java.browse/browse-url "http://clojure.org")
"http://clojure.org"

Once you call this function the default browser will open with the page. Quite handy, isn’t it? And the sources of the function are easy to read through as well. It takes a mere minute.

It turned out that the function was already in my project (when I copied the part off the other project), but I had no time to read about and ultimately learn it. Now I did.

By the way, I don’t recommend reviewing the application as it appears quite old, and perhaps often misleading in its use of the web libraries. Stay away of it.

Be Sociable, Share!
This entry was posted in Languages.

Leave a Reply

%d bloggers like this: