reitit

Vivi Shi 2024-08-27T07:36:12.526479Z

hello,who can help me? I use [metosin/reitit "0.5.12"]. My edn result is {:Amount 957840012233445.57M}, a bigdec format. But when I use reitit to get a handler body. It will become {"Amount": 95784001223344.56}, resulting in some loss of precision. What should I do to keep data correct?

valtteri 2024-08-27T07:57:10.052339Z

Hi, the answer depends whether you’re using spec, plumatic schema or malli for coercion. You can find relevant docs here https://cljdoc.org/d/metosin/reitit/0.7.1/doc/coercion

😅 1
valtteri 2024-08-27T08:02:04.485549Z

An old trick is to serialize large numbers to strings which might be “good enough” for some cases.

Leo E 2024-08-27T14:27:23.178319Z

Hi all. What right way to make reitit-compatible interceptor from pedestal-interceptor? In my example i want to add io.pedestal.http.cors/allow-origin interceptor to path in reitit router. But allow-origin not implement IntoInterceptor protocol, so i got error. I make it like this, but it doesn't feel right

(defn convert-pedestal-to-reitit-interceptor
  [pedestal-interceptor]
  {:name (:name pedestal-interceptor)
   :enter (:enter pedestal-interceptor)
   :leave (:leave pedestal-interceptor)
   :error (:error pedestal-interceptor)})
Also interesting why extend-protocol reitit.interceptor/IntoInterceptor not support for io.pedestal.interceptor/Interceptor