Fork me on GitHub

@henrik. Looks like you've quoted common-interceptors in the second case.


Oh, right, so now I’ve learned about backtick.


Why are the routes quoted to begin with? I’m working from the leiningen template.


@henrik, I’ve not looked at the impl for map-based routes so I can’t comment on them. My preference is the tabular routing syntax. I find them much easier to grok.


Fair enough. In the case of tabular routes, the back tick sits on the routing function itself. In the “hello world” guide, there’s no back tick:

(def routes
   #{["/greet" :get respond-hello :route-name :greet]}))
In the template, the routing is split between service.clj:
;; Tabular routes
(def routes #{["/" :get (conj common-interceptors `home-page)]
              ["/about" :get (conj common-interceptors `about-page)]})
and server.clj:
(-> service/service ;; start with production configuration
      (merge {…
              ::server/routes #(route/expand-routes (deref #'service/routes))
What’s the deal with the back-ticks in the first file and the deref in the other? Why are they there and what do they do?


The backticks in service.clj lead to fully qualified symbols that get resolved here:


The deref allows routes to be reloaded without having to restart the server


you can make changes and load the service ns again