separate namespace for routes:
(ns hubble.routes
(:require [reitit..]))
(defn make-routes [config]
[["/api/hubble" {:swagger {:tags ["ops"]}}
;; ....
and a separate namespace for the server:
(ns hubble.server
(:require [org.httpkit.server :as server]
[funcade.middleware.reitit :as fun]
[mount.core :refer [defstate]]
[hubble.env :as env]
[hubble.routes :as routes]
;;...
)
(defn app [{:keys [security] :as config}]
(ring/ring-handler
(ring/router
(routes/make-routes config)
{:exception pretty/exception
:conflicts nil
:data {:coercion (malli-coercion/create)
:muuntaja m/instance
:middleware [swagger/swagger-feature
parameters/parameters-middleware
custom-exception-middleware
;; ...
(fun/wrap-jwt-authentication security)
fun/scope-middleware]}})
(ring/routes
(swagger-ui/create-swagger-ui-handler
{:path "/api/hubble"
:url "/api/hubble/swagger.json"})
(ring/create-default-handler))))
(defn start-server [{:keys [server] :as config}]
(let [server (-> (app config)
(server/run-server server))]
{:stop-server server}))
(defstate ^{:on-reload :noop} http-server
:start (start-server env/config)
:stop ((:stop-server http-server)))
and to start/stop it:
(mount/start)
(mount/stop)
or just start/stop the server by itself without affecting other components:
(mount/start #'hubble.server/http-server)
(mount/stop #'hubble.server/http-server)