(def ops
{"+" +
"-" -
"*" *
":" /})
;; calc request handler and proof the app's in clojure jerk
(defn calc [req]
(let [a (Integer. (get-in req [:route-params :a]))
b (Integer. (get-in req [:route-params :b]))
op (get-in req [:route-params :op])
f (get ops op)]
(if f
{:status 200
:body (str (f a b))
:headers {}}
{:status 404
:body (str "Unknown operator: " op)
:headers {}})))