forest.response

Passes content to response object with some useful formats.

download

(download content)(download filename content)

Sets HTTP headers to force web browsers to download the string content as file instead of displaying it inline.

You could even set the filename differently than the requested URI.

edn

(edn body)(edn status body)

Receives a status (optional) and a Clojure data structure body, returns a map that can be passed to response

json

(json body)(json status body)

Receives a status (optional) and a Clojure data structure body. Will coerce body to a JSON string and return a map that can be passed to response

json'

(json' body)(json' status body)

Receives a status (optional) and a javascript data structure body. Will stringify body and return a map that can be passed to response

json*

(json* body)(json* status body)

Receives a status (optional) and a JSON string body, returns a map that can be passed to response

response

(response res content)

Sets headers, status and body for the given response object res according to those defined in content. Use it inside a request handler.