Routing
Shipclojure uses reitit for both frontend and backend routing because it is the fastest router in the clojure ecosystem and it is data oriented (you can represent your routes as vectors):
(def routes ["/" {:handler (fn [req] {:status 200 :body "Hello"})}])
Fair warning: Reitit is a bit hard to grasp as first but no worries since most of the middleware and hard wiring is done for you.
Swagger
Shipclojure uses swagger for documentation, if you have your server running, visiting http://localhost:8080/api should show you the swagger documentation for all routes: api, web routes & websocket.
Routes
The routes are split into 3 categories:
REST api routes: api.clj
Websocket routes: websocket.clj
Frontend routes (mix of static pages rendered on the backend and frontend only routes): common/routes.cljc
How to know which frontend routes are server rendered and which are frontend only: Frontend routes will have a
:view
while backend routes will have the normal syntax of:get/:post (fn [req] (render-page req))
.Example
(def routes ["" #?(:clj {:get root}) ;; the default empty html that just renderes on the frontend ["/" (merge {:seo/title "Home" :seo/description "The SaaS boilerplace for your next project" :name ::index} ;; Rendered on the backend #?(:clj {:get layout/landing-page}))] ["/verify" (merge {:name ::verify :seo/title "Verify your account" :seo/description "Finish creating account by confirming your email"} ;; Rendered frontend only #?(:cljs {:view verify/verify-email-page}))]])
Middleware
The shipclojure router has middleware already setup for your convenience.
See all the middleware here: handler.clj
Here is the documentation for reitit middleware
Websockets
Websockets use ring.websocket. Read the documentation to understand how it works.
Last updated