Fork me on GitHub
#reitit
<
2020-12-08
>
Ronny Li01:12:22

Hi, I've seen some reitit handlers extract the following keys from request:

{:keys [path-params query-params body-params]}
Yet when I inspect my request map I only see
:query-string
:path-params
:body
Does anyone know the reason for this discrepancy? Am I on the wrong version of reitit? I'm using [metosin/reitit "0.5.10"]

3
Dave Russell15:12:01

It's perhaps also worth noting that query-params can come from the https://github.com/ring-clojure/ring/blob/1.7.0/ring-core/src/ring/middleware/params.clj#L48 that does the same. You don't have to use the reitit middlewares, but they are data-driven so they play nicely with the middleware chain.

Dave Russell15:12:27

It's the same with body-params. We have our own middleware that handles JSON parsing (i.e. we're not using muuntaja for historical reasons), but we inject the data into :body-params so that we can leverage reitit coercion to inspect and coerce the data therein

Dave Russell15:12:57

It's really up to you!