io.pedestal.http.body-params
custom-edn-parser
(custom-edn-parser & options)
Return an edn-parser fn that, given a request, will read the body of that request with edn/read
. options are key-val pairs that will be passed as a hash-map to edn/read
.
custom-json-parser
(custom-json-parser & options)
Return a json-parser fn that, given a request, will read the body of that request with json/read
. options are key-val pairs that will be passed along to json/read
.
custom-transit-parser
(custom-transit-parser & options)
Return a transit-parser fn that, given a request, will read the body of that request with transit/read
. options is a sequence to pass to transit/reader along with the body of the request.
default-parser-map
(default-parser-map & parser-options)
Return a map of MIME-type to parsers. Included types are edn, json and form-encoding. parser-options are key-val pairs, valid options are:
:edn-options A hash-map of options to be used when invoking edn/read
. :json-options A hash-map of options to be used when invoking json/parse-stream
. :transit-options A vector of options to be used when invoking transit/reader
- must apply to both json and msgpack
Examples:
(default-parser-map :json-options {:key-fn keyword}) ;; This parser-map would parse the json body ‘{“foo”: “bar”}’ as ;; {:foo “bar”}
(default-parser-map :edn-options {:readers data-readers}) ;; This parser-map will parse edn bodies using any custom edn readers you ;; define (in a data_readers.clj file, for example.)
(default-parser-map :transit-options {:handlers {“custom/model” custom-model-read-handler}}) ;; This parser-map will parse the transit body using a handler defined by ;; custom-model-read-handler.