Search code examples
clojureringcompojure

How do I use Ring to output my post data in a request?


In using clojure-ring I'm trying to do a simple test by posting data form a form and then printing it to the browser.

(defroutes approutes
  ;posting test
  (POST "/upload" [req]
    (str "the wonderful world of wonka presents " req)))

when I try posting data via curl it gives me a 200 okay status code, but it doesn't actually fill in the body of the request with the params. Perhaps I am overlooking something fundamental about Ring.

edt: what it does output is

the wonderful world of wonka presents

but the rest doesn't show up.


Solution

  • compojure's destructuring tries to access the query/form parameter :req in your example, not the whole request. You have two possibilities:

    (POST "..." req ...)
    

    and

    (POST "..." [something :as req] ...)
    

    Both store the request in req, the second variant allows you to still use destructuring , though.