Skip to content

Commit

Permalink
Merge pull request #130 from markokocic/reitit-reload
Browse files Browse the repository at this point in the history
Implement reitit reloading
  • Loading branch information
yogthos authored Feb 14, 2024
2 parents a0b246a + 862914a commit 364b157
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 6 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ profiles.clj
pom.xml.asc
*.jar
*.class
*.bak
.lein-*/
.nrepl-port/
.prepl-port/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ modules/
# IntelliJ
*.iml
.idea/
*.bak

# clj-kondo
.clj-kondo/.cache/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,8 @@
{:routes #ig/refset :reitit/routes}

:router/core
{:routes #ig/ref :router/routes} <% if quartz? %>
{:routes #ig/ref :router/routes
:env #ig/ref :system/env} <% if quartz? %>

:cronut/scheduler
{:schedule []}<% endif %> <% if selmer? %>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
(defmethod ig/init-key :handler/ring
[_ {:keys [router api-path] :as opts}]
(ring/ring-handler
router
(router)
(ring/routes
;; Handle trailing slash in routes - add it + redirect to it
;; https://github.com/metosin/reitit/blob/master/doc/ring/slash_handler.md
Expand All @@ -32,8 +32,15 @@

(defmethod ig/init-key :router/routes
[_ {:keys [routes]}]
(apply conj [] routes))
(mapv (fn [route]
(if (fn? route)
(route)
route))
routes))

(defmethod ig/init-key :router/core
[_ {:keys [routes] :as opts}]
(ring/router ["" opts routes]))
[_ {:keys [routes env] :as opts}]
(let [router #(ring/router ["" opts routes])]
(if (= env :dev)
router
(constantly router))))
Original file line number Diff line number Diff line change
Expand Up @@ -46,4 +46,4 @@
[_ {:keys [base-path]
:or {base-path ""}
:as opts}]
[base-path route-data (api-routes opts)])
(fn [] [base-path route-data (api-routes opts)]))

0 comments on commit 364b157

Please sign in to comment.