Search code examples
formsclojurerequestringbidi

How to get form data in bidi ring handler?


I am trying to access the form data in bidi.ring handler. A form submission is associated to a bidi.ring handler and I am not able get the form data in the request.

In some blog I foundform-params is the one. But the request object does not have this at all. I have also checked params route-params. All are nil.

For reference:


(defn index-handler [request]
  (if (= (:request-method request) :post)
   (let [title (get (:form-params request) "title")]
     (println title))))

(defn handler []
  (make-handler ["/" {"" index-handler}]))


(defrecord HttpServer [server]
  component/Lifecycle
  (start [this]
    (assoc this :server (http/start-server (handler) {:port 8080}))) ...)

What am I missing?


Solution

  • It looks like you have no further middleware setup. You need at least wrap-params. See the docs of bidi for details how to do so.