Liking cljdoc? Tell your friends :D

ring.util.response

Functions for generating and augmenting response maps.

Functions for generating and augmenting response maps.
raw docstring

bad-requestclj

(bad-request body)

Returns a 400 'bad request' response.

Returns a 400 'bad request' response.
raw docstring

charsetclj

(charset resp charset)

Returns an updated Ring response with the supplied charset added to the Content-Type header.

Returns an updated Ring response with the supplied charset added to the
Content-Type header.
raw docstring

content-typeclj

(content-type resp content-type)

Returns an updated Ring response with the a Content-Type header corresponding to the given content-type.

Returns an updated Ring response with the a Content-Type header corresponding
to the given content-type.
raw docstring

createdclj

(created url)
(created url body)

Returns a Ring response for a HTTP 201 created response.

Returns a Ring response for a HTTP 201 created response.
raw docstring

file-responseclj

(file-response filepath)
(file-response filepath options)

Returns a Ring response to serve a static file, or nil if an appropriate file does not exist. Options: :root - take the filepath relative to this root path :index-files? - look for index.* files in directories (defaults to true) :allow-symlinks? - allow symlinks that lead to paths outside the root path (defaults to false)

Returns a Ring response to serve a static file, or nil if an appropriate
file does not exist.
Options:
  :root            - take the filepath relative to this root path
  :index-files?    - look for index.* files in directories (defaults to true)
  :allow-symlinks? - allow symlinks that lead to paths outside the root path
                     (defaults to false)
raw docstring

find-headerclj

(find-header resp header-name)

Looks up a header in a Ring response (or request) case insensitively, returning the header map entry, or nil if not present.

Looks up a header in a Ring response (or request) case insensitively,
returning the header map entry, or nil if not present.
raw docstring

get-charsetclj

(get-charset resp)

Gets the character encoding of a Ring response.

Gets the character encoding of a Ring response.
raw docstring

get-headerclj

(get-header resp header-name)

Looks up a header in a Ring response (or request) case insensitively, returning the value of the header, or nil if not present.

Looks up a header in a Ring response (or request) case insensitively,
returning the value of the header, or nil if not present.
raw docstring

(header resp name value)

Returns an updated Ring response with the specified header added.

Returns an updated Ring response with the specified header added.
raw docstring

not-foundclj

(not-found body)

Returns a 404 'not found' response.

Returns a 404 'not found' response.
raw docstring

redirectclj

(redirect url)
(redirect url status)

Returns a Ring response for an HTTP 302 redirect. Status may be a key in redirect-status-codes or a numeric code. Defaults to 302

Returns a Ring response for an HTTP 302 redirect. Status may be 
a key in redirect-status-codes or a numeric code. Defaults to 302
raw docstring

redirect-after-postcljdeprecated

(redirect-after-post url)

Returns a Ring response for an HTTP 303 redirect. Deprecated in favor of using redirect with a :see-other status.

Returns a Ring response for an HTTP 303 redirect. Deprecated in favor
of using redirect with a :see-other status.
raw docstring

redirect-status-codesclj

Map a keyword to a redirect status code.

Map a keyword to a redirect status code.
raw docstring

resource-datacljmultimethod

(resource-data url)

Returns data about the resource specified by url, or nil if an appropriate resource does not exist.

The return value is a map with optional values for: :content - the content of the URL, suitable for use as the :body of a ring response :content-length - the length of the :content, nil if not available :last-modified - the Date the :content was last modified, nil if not available

This dispatches on the protocol of the URL as a keyword, and implementations are provided for :file and :jar. If you are on a platform where (Class/getResource) returns URLs with a different protocol, you will need to provide an implementation for that protocol.

This function is used internally by url-response.

Returns data about the resource specified by url, or nil if an
appropriate resource does not exist.

The return value is a map with optional values for:
:content        - the content of the URL, suitable for use as the :body
                  of a ring response
:content-length - the length of the :content, nil if not available
:last-modified  - the Date the :content was last modified, nil if not
                  available

This dispatches on the protocol of the URL as a keyword, and
implementations are provided for :file and :jar. If you are on a
platform where (Class/getResource) returns URLs with a different
protocol, you will need to provide an implementation for that
protocol.

This function is used internally by url-response.
raw docstring

resource-responseclj

(resource-response path)
(resource-response path options)

Returns a Ring response to serve a packaged resource, or nil if the resource does not exist. Options: :root - take the resource relative to this root :loader - resolve the resource in this class loader :allow-symlinks? - allow symlinks that lead to paths outside the root classpath directories (defaults to false)

Returns a Ring response to serve a packaged resource, or nil if the
resource does not exist.
Options:
  :root            - take the resource relative to this root
  :loader          - resolve the resource in this class loader
  :allow-symlinks? - allow symlinks that lead to paths outside the root
                     classpath directories (defaults to false)
raw docstring

responseclj

(response body)

Returns a skeletal Ring response with the given body, status of 200, and no headers.

Returns a skeletal Ring response with the given body, status of 200, and no
headers.
raw docstring

response?clj

(response? resp)

True if the supplied value is a valid response map.

True if the supplied value is a valid response map.
raw docstring

(set-cookie resp name value & [opts])

Sets a cookie on the response. Requires the handler to be wrapped in the wrap-cookies middleware.

Sets a cookie on the response. Requires the handler to be wrapped in the
wrap-cookies middleware.
raw docstring

statusclj

(status resp status)

Returns an updated Ring response with the given status.

Returns an updated Ring response with the given status.
raw docstring

update-headerclj

(update-header resp header-name f & args)

Looks up a header in a Ring response (or request) case insensitively, then updates the header with the supplied function and arguments in the manner of update-in.

Looks up a header in a Ring response (or request) case insensitively,
then updates the header with the supplied function and arguments in the
manner of update-in.
raw docstring

url-responseclj

(url-response url)

Return a response for the supplied URL.

Return a response for the supplied URL.
raw docstring

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

× close