                         (if keywords? " keywordize"))}))
 
 ;; XXX only implementing JSON format and not implementing prefixes for now since we don't use either
-(defn ajax [method url message channel & {:keys [params keywords? context]
+(defn ajax [method url message channel & {:keys [params keywords? context headers]
                                           :or {keywords? true}}]
   (let [uuid frontend.async/*uuid*]
     (put! channel [message :started context])

                             :finally #(binding [frontend.async/*uuid* uuid]
                                         (put! channel [message :finished context]))}))))

(defn managed-ajax [method url & {:keys [params keywords?]
                                  :or {keywords? true}}]
  (let [channel (chan)]
    (clj-ajax/ajax-request url method

                             :params params
                             :headers (merge {:Accept "application/json"}
                                             (when (re-find #"^/" url)
                                               {:X-CSRFToken (utils/csrf-token)})
                                             headers)
                             :handler #(binding [frontend.async/*uuid* uuid]
                                         (put! channel [message :success (assoc % :context context)]))
                             :error-handler #(binding [frontend.async/*uuid* uuid]
