Liking cljdoc? Tell your friends :D

Response Map

The response map is attached to the context-map.adoc by any interceptor in the interceptor chain. The response map describes the outgoing HTTP response. If no response map is attached to the context by the time processing is done, then Pedestal generates a 404 response.

When an interceptor attaches a response map (or a handler function returns a response map), the map is validated:

  • Must be a map

  • Must contain a positive integer value for the :status

If the response fails the above validations, an exception is thrown. [1]

The function api:respond-with[] is the easiest way to add a response map to the interceptor context.

KeyAlways Present?TypeDescription

:status

Y

integer

The HTTP status code

:headers

N

map of String → String

Response headers sent to the client. Header names are all converted to lower case.

:body

N

String, ISeq, File, InputStream

The body of the response sent to the client.

Application code that returns a header should use the proper case version of the header, for example, Content-Type (not content-type); although incoming request headers are converted to lower case, outgoing response headers are left as-is, and some standard interceptors expects certain headers to be present with the correct name (such as Content-Type).

1. Prior to Pedestal 0.7, an invalid :response would be ignored instead, and the execution would continue, subverting the developer’s expectations.

Can you improve this documentation?Edit on GitHub

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

× close