This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2023-03-05
Channels
- # announcements (1)
- # asami (1)
- # babashka (7)
- # beginners (11)
- # biff (2)
- # calva (7)
- # cider (1)
- # clara (5)
- # clj-kondo (223)
- # clojure (83)
- # clojure-boston (3)
- # clojure-conj (1)
- # clojure-europe (9)
- # clojure-uk (1)
- # clojurescript (11)
- # cursive (76)
- # emacs (30)
- # figwheel-main (2)
- # fulcro (13)
- # hyperfiddle (6)
- # lsp (6)
- # malli (2)
- # nyc (4)
- # off-topic (78)
- # practicalli (9)
- # reitit (4)
- # sci (20)
- # shadow-cljs (49)
- # sql (9)
- # xtdb (5)
Can someone please share a trivial example of using xtdb.http-server/->xtdb-handler
with reitit.ring
and muuntaja
? I can't figure it out. Thanks
I think I figured it out. Now, it works for routes like xtdb/status, but doesn't work for xtdb/query. Its :body is of type StreamableResponse and I don't know how to deal with it.
Doing lamebrain way like this worked, but that's probably not good:
(let [{:keys [body] :as res}
((->xtdb-handler my-node {}) req)]
(assoc res :body
(slurp (io/input-stream body))))
assuming the xtdb handler comes with all the middleware it needs (except for auth), maybe better to route xtdb requests to it without going through reitit or muuntaja first? e.g. put some middleware at/near the top of your middleware stack that checks if the request starts with _xtdb and passes it to the xtdb handler if so
Yeah, that probably would be a better way. For now, I just did this: (def app (ring/ring-handler (ring/router [["/data/*" xtdb-handler]]))) (jetty/run-jetty app opts) (defn xtdb-handler [{:keys [uri] :as req}] (let [req* (assoc req :uri (str/replace uri "/data/" "/_xtdb/")) {:keys [body] :as res} ((->xtdb-handler xtdb/my-node {}) req*)] (assoc res :body (slurp (io/input-stream body)))))