Beautiful code
I just took the time to start reading Tom Faulhaber's description of simple webhooks with Clojure and Ring. A mere two pages in I hit some staggeringly beautiful code.
I hope Tom won't mind me quoting it here:
(defn hook-server
"Build a simple webhook server on the specified
port. Invokes ring to fill a blocking queue,
whose elements are processed by handle-payload."
[port]
(doseq [payload
(fill-queue
(fn [fill]
(ring.jetty/run {:port port}
(partial app fill)))
:queue-size 10)]
(handle-payload payload)))
Go read the article and figure out the control flow there. Once you get it, wow. Defining an app in terms of a sequence generated by incoming requests.
This is why I love programming as a profession.
Posted at 2009-09-18 14:44:00 by Richard Newman • Link to Beautiful code
