Skip to content

bri.config

Two layers into one plain map: conf.ednAPP_* env. No config classes, no watchers, no remote sources.

(def cfg (config/load!)) ; reads a file (and the env), no more
(:port cfg) ; a plain map — get/get-in like any other

This is the cfg you saw on the golden page in the tutorial: a top-level def that constructs a value, with no other I/O.

Profiles are a :profiles section, not a file family:

{:port 3000
:db {:host "localhost" :pool-size 5}
:profiles
{:dev {}
:test {:db {:host "test-db"}}}}

APP_PROFILE selects the overlay (default dev; cljgo dev sets dev, cljgo test sets test). The selected profile deep-merges over the base map.

APP_* variables win over the file. The mapping is deterministic: __ (double underscore) separates path segments, single _ joins words —

APP_PORT=8080 → [:port]
APP_DB__POOL_SIZE=9 → [:db :pool-size]

Values coerce: all-digit → integer, true/false → boolean, else string. Durations and sizes are numbers (seconds, bytes) — no stringly-typed "5m".

The schema (optional, enforced when present)

Section titled “The schema (optional, enforced when present)”

conf.schema.edn — generated minimal by cljgo new --template web, delete it to go schemaless:

{[:port] {:type :int :required true :default 3000}}
  • :default is the lowest layer (file, profile, and env all beat it).
  • :required missing from every layer → load! throws before any server/pool/worker starts, naming the key. Misconfigured deploys must not boot.
  • :type (:int :number :string :boolean :keyword) mismatches name the key and the layer that supplied the bad value.
$ cljgo config
profile: dev
[:db :host] "localhost" <- file
[:db :pool-size] 9 <- env
[:port] 3000 <- file

Every key, its effective value, and the layer that won (default < file < profile < env).

  • Tutorial — the full 15-minute walkthrough where config/load! fits
  • bri.http — the server that consumes (:port cfg) and APP_SESSION_KEY
  • bri.html — pages and forms

Questions or feedback on this page? Comment below with your GitHub account — comments are public and live in the project's GitHub Discussions.