(ns worker.http-client
  (:require [clj-http.client :as http]))

(defn wrap-user-agent
  "Wrapper around clj-http.client/request, setting User-Agent to custom string."
  [client]
  (fn [req]
   (let [headers (or (:headers req) {})
         headers-agent (merge headers {"User-Agent" "Custom user agent"})]

     (client (merge req {:headers headers-agent})))))

(def request
  (wrap-user-agent http/request))

Generated by Scott Jaderholm using scpaste at Sun May 27 07:16:05 2012. PDT. (raw)