     [request]
     (file-utils/slurp- (:body request)))
 
-(defn body->job-name
+(defn body->results
     [body]
-    (let [data (json/read-str body)]
-        (get data "name")))
+    (json/read-str body))
+
+(defn read-job-name-from-uri
+    [uri]
+    (-> uri
+        (subs (inc (.lastIndexOf uri "/")))
+        (clojure.string/replace "+" " ")))
+
+(defn read-job-name-from-request
+    [request]
+    (read-job-name-from-uri (:uri request)))
 
 (defn send-response
     [response]

(ns emender-service.rest-api)

(require '[ring.util.response     :as http-response])
(require '[clojure.data.json      :as json])

(require '[emender-service.file-utils :as file-utils])


(defn job-started-handler
    [request]
    (let [job-name (read-job-name-from-request request)]
        (println "job started" job-name)
        (send-response {:status :ok})))

(defn job-finished-handler
    [request]
    (let [job-name (read-job-name-from-request request)]
        (println "job finished" job-name)
        (send-response {:status :ok})))

(defn job-results-handler
    [request]
    (let [job-name (read-job-name-from-request request)
          results  (-> (read-request-body request) body->results)]
        (println "job name" job-name)
        (println "results:" results)
        ;(pprint/pprint results)
        (send-response {:status :ok})))

