Fork me on GitHub
#reitit
<
2024-01-07
>
Joseph Graham12:01:16

how typically does one handle posted form data with reitit? I tried adding ring.middleware.multipart-params to my middleware, and setup my coercion with spec like this:

:post {:handler hl/post-handler
       :parameters {:path {:question_id ::id}
       :params {:choice ::id}}}
I can access question_id in (-> request :parameters :path :question_id) . However can't seem to access :choice .

skynet15:01:47

I do it with :form in :parameters :

{:parameters {:form {:choice ::id}}}
then access in
(-> request :parameters :form :choice)

Joseph Graham16:01:14

ah, that's it! not sure why I was using :params

👍 1
Joseph Graham12:01:38

also what order are the middlewares evaluated? I made a middleware to just pretty-print the request map to a file, but whether I put it at the beginning or end it still seems the other middlewares have already run

Joseph Graham12:01:51

do they run top-to-bottom?

Joseph Graham12:01:27

yes they do I tested with a middleware that outputs a timestamp