Fork me on GitHub
#reitit
<
2021-05-16
>
juri12:05:03

Hi. I'm wondering if it's possible to have both GET and POST for the same route with reitit? When I try the following I get an error

manutter5112:05:10

Sure, you just have to nest it instead of listing it as a series of empty routes:

{"/polls"
  {:middleware [middleware/wrap-csrf middleware/wrap-formats]
   :name "Polls"
   :get {:handler #'my/get-handler}
   :post {:handler #'my/post-handler}}
Caveat: that’s my early morning, pre-coffee, top-of-my-head code, I think it’s correct but no guarantees. That’s the general idea tho.

juri13:05:48

Ah now I see, thanks! I tried something earlier but it didn't work. But this worked