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 conformed format-opts)
source

format-entityclj

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

Index entities by ent-type and id-keys

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

format-responseclj

(format-response response)

Formats a response body to consist of segments unless formatter is ::raw.

Formats a response body to consist of segments unless formatter
is ::raw.
sourceraw docstring

format-segments-responseclj

(format-segments-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 ::segments.

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
::segments.
sourceraw docstring

format-typecljmultimethod

source

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

× close