A dead simple config reader for Clojure supporting multiple formats and extensions.
A dead simple config reader for Clojure supporting multiple formats and extensions.
(read-config from _ format)Reads a configuration file from from (a resource path string or reader)
and parses it according to format.
Supported formats: :edn - EDN file, returns a Clojure data structure :properties - Java .properties file, returns a map of string keys to string values
New formats can be supported by extending the -read-format multimethod,
which dispatches on the format keyword. For example, to add JSON support
using a library like cheshire:
(defmethod fogus.config/-read-format :json
[_ contents]
(cheshire.core/parse-string contents true))
With that in place, callers can use the :json tag to read those JSON config files.
Unrecognized format keywords fall through to the :default EDN parsing.
Reads a configuration file from `from` (a resource path string or reader)
and parses it according to `format`.
Supported formats:
:edn - EDN file, returns a Clojure data structure
:properties - Java .properties file, returns a map of string keys to string values
New formats can be supported by extending the `-read-format` multimethod,
which dispatches on the format keyword. For example, to add JSON support
using a library like `cheshire`:
(defmethod fogus.config/-read-format :json
[_ contents]
(cheshire.core/parse-string contents true))
With that in place, callers can use the `:json` tag to read those JSON config files.
Unrecognized format keywords fall through to the `:default` EDN parsing.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 |