Liking cljdoc? Tell your friends :D

pg.ring.json

Like ring.middleware.json but faster because uses internal JSON engine instead of Cheshire.

Like `ring.middleware.json` but faster because uses
internal JSON engine instead of Cheshire.
raw docstring

CT_JSONclj

source

json-request?clj

(json-request? request)

True if it was a request with JSON payload.

True if it was a request with JSON payload.
sourceraw docstring

JSON_ERRclj

source

RESP-JSON-MALFORMEDclj

source

wrap-jsonclj

(wrap-json handler)
(wrap-json handler options)

Two in one: wrap a handler with wrap-json-request and wrap-json-response. All the optional parameters are supported.

Two in one: wrap a handler with wrap-json-request
and wrap-json-response. All the optional parameters
are supported.
sourceraw docstring

wrap-json-requestclj

(wrap-json-request handler)
(wrap-json-request handler
                   {:keys [slot object-mapper malformed-response]
                    :or {slot :json malformed-response RESP-JSON-MALFORMED}})

If it was a JSON request, parse the body and assoc the data into a dedicated field. We do not overwrite the :body field because it's still might be needed to calculate a checksum, for example.

Suports the following options:

  • :slot -- the field where the parsed JSON data gets associated;
  • :malformed-response -- a response map which gets returned when we could not parse the payload. Default is 400 with a plain text error message;
  • :object-mapper -- an instance of com.fasterxml.jackson.databind.ObjectMapper for custom JSON encoding and decoding.
If it was a JSON request, parse the body and assoc the data
into a dedicated field. We *do not* overwrite the :body field
because it's still might be needed to calculate a checksum,
for example.

Suports the following options:
- :slot -- the field where the parsed JSON data gets associated;
- :malformed-response -- a response map which gets returned
  when we could not parse the payload. Default is 400 with
  a plain text error message;
- :object-mapper -- an instance of `com.fasterxml.jackson.databind.ObjectMapper`
  for custom JSON encoding and decoding.
sourceraw docstring

wrap-json-responseclj

(wrap-json-response handler)
(wrap-json-response handler {:keys [object-mapper]})

If the :body of the response is a collection, JSON-encode it and add a corresponding HTTP header.

Supports the following options:

  • :object-mapper -- an instance of com.fasterxml.jackson.databind.ObjectMapper for custom JSON encoding and decoding.
If the :body of the response is a collection, JSON-encode
it and add a corresponding HTTP header.

Supports the following options:

- :object-mapper -- an instance of `com.fasterxml.jackson.databind.ObjectMapper`
  for custom JSON encoding and decoding.
sourceraw docstring

cljdoc is a website building & hosting documentation for Clojure/Script libraries

× close