Fork me on GitHub
#reitit
<
2021-12-28
>
dharrigan16:12:01

If anyone is interested, I've put together a very simple example of using reitit + sente + plain ol'javascript (client) as a demonstration of websockets working between a javascript client and a clojure backend. Links are: and . The projects are not sophisticated (i.e., no authentication apart from a simple, non-secure, csrf check). It's merely to show a starting point. Enjoy!

👍 4
🎁 1
🎉 1
Noah Bogart17:12:06

this is excellent! thank you!

dharrigan18:12:46

You're most welcome. I've updated the repo just to tidy up some things and to link to the javascript client.

Janet A. Carr22:12:22

Hey folks, I'm having a bit of trouble getting the body-params out of muuntaja in my ring router. I practically lifted it from the reitit examples in the repo, but everytime the body-params (x and y) are nil. Anyone see any issues with my router?

(def router
  (ring/ring-handler
   (ring/router
    [["/plain"
      ["/plus" {:get (fn [{{:strs [x y]} :query-params :as req}]
                       {:status 200
                        :body {:total (+ (Long/parseLong x) (Long/parseLong y))}})
                :post (fn blah [{{:keys [x y]} :body-params}]
                        {:status 200
                         :body {:total (+ x y)}})}]]]
    {:data {:coercion reitit.coercion.spec/coercion
            :muuntaja m/instance
            :middleware [parameters/parameters-middleware
                         muuntaja/format-middleware
                         coercion/coerce-exceptions-middleware
                         coercion/coerce-request-middleware
                         coercion/coerce-response-middleware]}})
   (ring/create-default-handler)))