Commits

Miki Tebeka committed 9535712

parse-tropo

Comments (0)

Files changed (1)

   (:use appengine.datastore
         appengine.users 
         clojure.contrib.prxml
-        [clojure.contrib.json :only [json-str]]
-        [clojure.contrib.io :only [slurp*]]
+        [clojure.contrib.json :only [json-str read-json]]
+        [clojure.java.io :only [reader]]
         compojure.core
         hiccup.core
         hiccup.form-helpers
 (defn welcome-page []
   (page "Playing with Tropo"))
 
+(defn parse-tropo [body]
+  (:session (read-json (reader body))))
+
 (defroutes tropo-routes
   (GET "/" [] (welcome-page))
 
   (POST "/tropo/sms" {params :params} (tropo-sms params))
-  (POST "/tropo/voice" {body :body} (tropo-voice (slurp* body)))
+  (POST "/tropo/voice" {body :body} (tropo-voice (parse-tropo body)))
 
 ; Uncomment these when debugging, *don't* let them slip to production           
 ;  (GET "/_eval" [] (eval-page "0"))