Liking cljdoc? Tell your friends :D

sweet-tooth.endpoint.format

Conforms endpoint response bodies to the format that the frontend expects. The Sweet Tooth frontend 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 frontend 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 conformed format-opts)
source

format-body-dataclj

(format-body-data data opts)
source

format-entityclj

(format-entity entity {:keys [id-key] :as _format-opts})

Index entities by ent-type and id-keys

Index entities by ent-type and id-keys
sourceraw docstring

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

× close