I am trying to make a very simple API using ring in clojure. I am using rack.middleware.format-params middleware to convert output to json and input from json to clojure data structures.
I have an output that works beautifully, but I canβt for the whole life access the parameters sent via json. Here is some code that works for receiving requests, but I cannot receive a POST request to return the json that it receives
(ns testing.core
(:use [compojure.core]
[ring.middleware.format-params :only [wrap-json-params]]
[ring.middleware.format-response :only [wrap-json-response]]
[ring.adapter.jetty])
(:require [compojure.handler :as handler]))
(defroutes app-routes
(GET "/"
[]
{:body {:hello "world"}})
(POST "/"
{params :params}
{:body params}))
(def app
(-> (handler/api app-routes)
(wrap-json-params)
(wrap-json-response)))
It just returns this: {}
What am I doing wrong?
source
share