Fork me on GitHub
#reitit
<
2020-02-05
>
thelittlesipper15:02:29

How would one go about incorporating sente with reitit? Sente example:

(defroutes my-app-routes
  ;; <other stuff>

  ;;; Add these 2 entries: --->
  (GET  "/chsk" req (ring-ajax-get-or-ws-handshake req))
  (POST "/chsk" req (ring-ajax-post                req))
  )
Would this be the equivalent?
(def app
  (ring/ring-handler
    (ring/router
      [["/ping" (constantly {:status 200, :body "pong"})]
       ;; added the below chsk route
       ["/chsk"
        {:get {:summary "Receive on websocket"
               :handler #(ring-ajax-get-or-ws-handshake %)}
         :post {:summary "Send on websocket"
                :handler #(ring-ajax-post %)}}]])
    (ring/routes
      (ring/create-resource-handler {:path "/"})
      (ring/create-default-handler))))

ikitommi15:02:58

@sansaripour looks good to me. You can just say :handler ing-ajax-get-or-ws-handshake

ikitommi15:02:09

if you don’t need the :summary metadata, you can compact to:

["/chsk" {:get ring-ajax-get-or-ws-handshake, :post ring-ajax-post}]

👀 4
thelittlesipper15:02:43

Much better, I definitely do prefer that! Thanks again