Commit db219e41 authored by Ole Voldsæter's avatar Ole Voldsæter
Browse files

see end-to-end#56 simplified http handling

parent 222e8a9f
Pipeline #14331 passed with stages
in 1 minute and 49 seconds
......@@ -554,7 +554,7 @@
[varlistz]
{:variables []
:other-vars (reduce
#(assoc %1 (get %2 "input_file_name") (split (get %2 "variables") #"\s+"))
#(assoc %1 (get %2 "input_file_name") (-> (get %2 "variables") clojure.string/trim (clojure.string/split #"\s+")))
{:default []}
varlistz
)
......
......@@ -54,24 +54,12 @@
)
(POST "/" {:keys [headers body] :as request}
(if (= (get-in request [:headers "content-type"]) "application/json")
; do json request
(let [payload (parse-string (body-string request))
payload (get payload "parameters" payload)
stata (get payload "stata")
variables (get payload "data_file_descriptions")]
{:headers {"Content-Type" "application/json"}
:body (to-json stata variables "N/A")}
)
; do form data request
(let [request (params-request request)
stata (get-in request [:params "stata"]),
variables (parse-string (get-in request [:params "data_file_descriptions"]))
accept (get-in request [:headers "accept"])
output (to-json stata variables "N/A")]
(prn (:headers request))
{:headers {"Content-Type" accept} :body output}
)
(let [payload (parse-string (body-string request))
payload (get payload "parameters" payload)
stata (get payload "stata")
variables (get payload "data_file_descriptions")]
{:headers {"Content-Type" "application/json"}
:body (to-json stata variables "N/A")}
)
)
)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment