Fork me on GitHub
#reitit
<
2022-03-27
>
Ben Sless13:03:46

Any chance for a look at https://github.com/metosin/reitit/pull/506? The overhead of keywordizing the keys can be larger than any other component in the server 😿

💯 2
Ben Sless13:03:59

Also found out how to compose binary functions, which would enable compiling the request coercers:

(defn compile-coerce-request [coercers]
  (reduce-kv
   (fn [f-acc k coercer]
     (let [f (fn assoc-coercered [acc request]
               (impl/fast-assoc acc k (coercer request)))]
       (fn comp-coercsion [acc request]
         (let [ret (f-acc acc request)]
           (f ret request)))))
   (fn [acc _request] {})
   coercers))

((compile-coerce-request
  {:a #(inc (get % :x))
   :b #(dec (get % :y))
   :c #(dec (get % :z))
   })
 {}
 {:x 1 :y 2 :z 3})