Liking cljdoc? Tell your friends :D

sweet-tooth.endpoint.format

Conforms endpoint response bodies to the format that the frontend expects. The Sweet Tooth frotend expects responses in the form of

[[:entity {:ent-type {ent-id {:entity :map}}}]]

The vector [:entity ...] is a segment. A response contains 0 or more segments. This format was chosen to better support composition in responses: If you need to add more information to a response, you can add a new segment without concern for what the response already contains.

However, it would be tedious to have to format the response body of every single endpoint this way, when most the time you just want to return one or more entities. You should be able to just return the entities; this namespace lets you do that.

Basically, returning a map or vector of maps is shorthand for the full entity segment.

Conforms endpoint response bodies to the format that the frontend expects.
The Sweet Tooth frotend expects responses in the form of

`[[:entity {:ent-type {ent-id {:entity :map}}}]]`

The vector `[:entity ...]` is a segment. A response contains 0 or
more segments. This format was chosen to better support composition
in responses: If you need to add more information to a response, you
can add a new segment without concern for what the response already
contains.

However, it would be tedious to have to format the response body of
every single endpoint this way, when most the time you just want to
return one or more entities. You should be able to just return the
entities; this namespace lets you do that.

Basically, returning a map or vector of maps is shorthand for the
full entity segment.
raw docstring

format-bodyclj

(format-body body id-key ent-type conformed)
source

format-responseclj

(format-response {:keys [body] :as response})

Assumes that the default response from endpoints is a map or vector of maps of a single ent-type. Formats that so that it conforms to response.

Assumes that the default response from endpoints is a map or vector
of maps of a single ent-type. Formats that so that it conforms to
response.
sourceraw docstring

wrap-skip-formatclj

(wrap-skip-format f)

skip-format is a flag read by formatting middleware that indicates that the response should not be formatted.

`skip-format` is a flag read by formatting middleware that indicates
that the response should not be formatted.
sourceraw docstring

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

× close