Provides interceptors and support for parsing the body of a request, generally according to the content type header. This results in new keys on the request map, depending on the type of data parsed.
Provides interceptors and support for parsing the body of a request, generally according to the content type header. This results in new keys on the request map, depending on the type of data parsed.
(add-parser parser-map content-type parser-fn)
Adds a parser to the parser map; content type can either be a string (to exactly match the content type), or a regular expression.
The parser-fn is passed the request map and returns a modified request map with an appropriate key and parsed value. For example, the default JSON parser adds a :json-params key.
Adds a parser to the parser map; content type can either be a string (to exactly match the content type), or a regular expression. The parser-fn is passed the request map and returns a modified request map with an appropriate key and parsed value. For example, the default JSON parser adds a :json-params key.
(body-params)
(body-params parser-map)
Returns an interceptor that will parse the body of the request according to the content type.
The normal rules are provided by default-parser-map
which maps a regular expression identifying a content type
to a parsing function for that type.
Parameters parsed from the body are added as a new key to the request map dependending on which parser does the work; for the default parsers, one of the following will be used:
Returns an interceptor that will parse the body of the request according to the content type. The normal rules are provided by [[default-parser-map]] which maps a regular expression identifying a content type to a parsing function for that type. Parameters parsed from the body are added as a new key to the request map dependending on which parser does the work; for the default parsers, one of the following will be used: - :json-params - :edn-params - :form-params - :transit-params
(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
.
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 & options)
Return a json-parser fn that, given a request, will read the body of the
request with json/parse-stream
. options are key-val pairs that will be passed along
to json/parse-stream
.
Return a json-parser fn that, given a request, will read the body of the request with `json/parse-stream`. options are key-val pairs that will be passed along to `json/parse-stream`.
(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.
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 & 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.
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.
(form-parser request)
Take a request and parse its body as a form.
Take a request and parse its body as a form.
cljdoc is a website building & hosting documentation for Clojure/Script libraries
× close