Fork me on GitHub
#reitit
<
2021-01-13
>
Oz01:01:39

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.

aratare11:01:19

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?

manutter5112:01:54

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

manutter5112:01:57

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

aratare12:01:26

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

aratare12:01:18

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

manutter5112:01:12

we’ve got a function that looks like this:

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

manutter5112:01:34

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

aratare13:01:18

no luck so far

aratare13:01:39

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

aratare14:01:09

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.