reitit

https://cljdoc.org/d/metosin/reitit/ https://github.com/metosin/reitit/
Oz 2021-01-13T01:36:39.052300Z

Looks like my problem was solved by changing the parameters I pass to apply-controllers. I used the ::navigated event from the frontend-re-frame example

(re-frame/reg-event-db ::navigated  
  (fn [db [_ new-match]] 
   (let [old-match (:current-route db)  
  controllers (rfc/apply-controllers (:controllers old-match) new-match)]    (assoc db :current-route (assoc new-match :controllers controllers)))))
I fixed it by passing (:controllers (:data old-match)) instead of (:controllers old-match) I think it's a mistake in the example.

aratare 2021-01-13T11:39:19.054500Z

Hi there. Is it normal to have form-params as a map of strings to strings? If so, is there a nice way to convert the keys to keywords instead?

2021-01-13T12:48:54.055200Z

There’s middleware for that-- muuntaja.middleware/wrap-format I think?

2021-01-13T12:49:57.055700Z

or maybe wrap-params… It’s been a while since I’ve looked at the code.

aratare 2021-01-13T12:51:26.056400Z

So I'm using these 3:

;; content-negotiation
                  muuntaja/format-negotiate-middleware
                  ;; encoding response body
                  muuntaja/format-response-middleware
                  ;; decoding request body
                  muuntaja/format-request-middleware
but by the time it hits the handler the params is still a map of strings to strings

aratare 2021-01-13T12:52:18.056700Z

I'll give wrap-format a try. Thanks 🙂

2021-01-13T12:54:12.057100Z

we’ve got a function that looks like this:

(defn wrap-formats
  [handler]
  (-> handler
      (wrap-params)
      (wrap-format muuntaja-opts)))

2021-01-13T12:54:34.057400Z

It’s fairly high/early in our root middleware stack.

aratare 2021-01-13T13:19:18.057600Z

no luck so far

aratare 2021-01-13T13:19:39.057900Z

at this point I'm pretty sure I've misconfigured something somewhere

aratare 2021-01-13T14:08:09.058900Z

in the end I decided to use :parameters -> :form instead. Never got form-params to be properly converted without having to write a custom middleware for it.