   (:require [cavm.query.sources :as sources])
   (:require [ring.util.codec :as codec])
   (:require [ring.util.response :as response ])
+  (:require [ring.util.request :refer [body-string] ])
   (:require [clojure.edn :as edn])
   (:require [clojure.data.json :as json])
   (:require [cavm.h2 :as h2])

; set of vectors. Not sure how it was supposed to work.

(defresource expression [exp]
  :available-media-types ["application/json" "application/edn"]
  :handle-ok (fn [{{db :db} :request}]
               (expr/expression exp f/functions (functions db))))



; XXX add the custom pattern #".+" to avoid nil, as above?
(defroutes routes
  (GET "/data/:exp" [exp] (expression exp))
  (POST "/data/" r (expression (body-string r)))
  (POST "/update/" [file :as {ip :remote-addr
                              loader :loader}] (loader-request ip loader file))
  (not-found "not found"))
