Fork me on GitHub
#pedestal
<
2017-06-19
>
deg12:06:17

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

henrik13:06:36

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

henrik13:06:28

Why are the routes quoted to begin with? I’m working from the leiningen template. https://github.com/pedestal/pedestal/tree/master/service-template/src/leiningen/new/pedestal_service

ddeaguiar16:06:02

@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.

henrik16:06:58

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
  (route/expand-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?

ddeaguiar16:06:42

The backticks in service.clj lead to fully qualified symbols that get resolved here: https://github.com/pedestal/pedestal/blob/master/interceptor/src/io/pedestal/interceptor.clj#L49

ddeaguiar16:06:03

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

ddeaguiar16:06:23

you can make changes and load the service ns again