Optional: Integrant methods for a host that uses it (SPEC §10). The only
namespace of the base that requires integrant; nothing else depends on it,
and a host without Integrant calls dev.arkaitz.web-base/handler and
start itself.
A config for ::handler holds functions — routes, the subject function,
layouts — which EDN cannot express, so a host writes it as an Integrant
component of its own and refers to it, or builds the map in code:
{::wb/handler {:routes #ig/ref :my/routes :session {...} ...}
::wb/server {:handler #ig/ref ::wb/handler :port 3000}}
config/readers is merged in so #wb/env works in the same EDN, and the
two-argument form takes readers of the host's own.
Optional: Integrant methods for a host that uses it (SPEC §10). The only
namespace of the base that requires integrant; nothing else depends on it,
and a host without Integrant calls `dev.arkaitz.web-base/handler` and
`start` itself.
A config for `::handler` holds functions — routes, the subject function,
layouts — which EDN cannot express, so a host writes it as an Integrant
component of its own and refers to it, or builds the map in code:
{::wb/handler {:routes #ig/ref :my/routes :session {...} ...}
::wb/server {:handler #ig/ref ::wb/handler :port 3000}}
`config/readers` is merged in so `#wb/env` works in the same EDN, and the
two-argument form takes readers of the host's own.(read-string s)(read-string readers s)Integrant's reader with the base's tags added, or with the readers given —
config/env-file-readers for a development machine, say.
Integrant's reader with the base's tags added, or with the readers given — `config/env-file-readers` for a development machine, say.
(run! {:keys [banner] :as options} args)The whole of a host's -main: reads config (a classpath resource), with the readers
of env-file when named, puts a port given as the first of args at port-path,
starts the system, prints (banner system), halts it on shutdown, and blocks the
calling thread — the server's threads do not keep a JVM alive on their own.
(defn -main [& args] (wbi/run! {:config "config.edn" :env-file "env.local.edn" :port-path [:my/port] :banner #(str "serving on " (get-in % [::wb/server :port]))} args))
A bad port, a missing or malformed resource, a variable nobody set, a system that
fails to start or a banner that throws prints one line to *err* — the failure's
message, never the configuration — and exits with status 1, whatever had started
halted first.
The whole of a host's `-main`: reads `config` (a classpath resource), with the readers
of `env-file` when named, puts a port given as the first of `args` at `port-path`,
starts the system, prints `(banner system)`, halts it on shutdown, and blocks the
calling thread — the server's threads do not keep a JVM alive on their own.
(defn -main [& args]
(wbi/run! {:config "config.edn"
:env-file "env.local.edn"
:port-path [:my/port]
:banner #(str "serving on " (get-in % [::wb/server :port]))}
args))
A bad port, a missing or malformed resource, a variable nobody set, a system that
fails to start or a banner that throws prints one line to `*err*` — the failure's
message, never the configuration — and exits with status 1, whatever had started
halted first.cljdoc builds & hosts documentation for Clojure/Script libraries
| Ctrl+k | Jump to recent docs |
| ← | Move to previous article |
| → | Move to next article |
| Ctrl+/ | Jump to the search field |