Set of recognised charsets by the current JVM
Set of recognised charsets by the current JVM
(can-encode? {:keys [enc-type] :as encoder}
{:keys [type sub-type] :as accepted-type})
Check whether encoder can encode to accepted-type. Accepted-type should have keys :type and :sub-type with appropriate values.
Check whether encoder can encode to accepted-type. Accepted-type should have keys *:type* and *:sub-type* with appropriate values.
Memoized form of choose-charset*
Memoized form of [[choose-charset*]]
(choose-charset* accept-charset)
Returns an useful charset from the accept-charset string. Defaults to utf-8
Returns an useful charset from the accept-charset string. Defaults to utf-8
(default-charset-extractor request)
Default charset extractor, which returns either Accept-Charset header field or utf-8
Default charset extractor, which returns either *Accept-Charset* header field or *utf-8*
(default-handle-error e _ _)
Default error handling function used, which rethrows the Exception
Default error handling function used, which rethrows the Exception
(make-encoder encoder content-type)
(make-encoder encoder content-type binary?)
Return a encoder map suitable for [[wrap-format-response.]] f takes a string and returns an encoded string type Content-Type of the encoded string (make-encoder json/generate-string "application/json")
Return a encoder map suitable for [[wrap-format-response.]] f takes a string and returns an encoded string type *Content-Type* of the encoded string (make-encoder json/generate-string "application/json")
Memoized form of parse-accept-header*
Memoized form of [[parse-accept-header*]]
(parse-accept-header* accept-header)
Parse Accept headers into a sorted sequence of maps. "application/json;level=1;q=0.4" => ({:type "application" :sub-type "json" :q 0.4 :level "1"})
Parse Accept headers into a sorted sequence of maps. "application/json;level=1;q=0.4" => ({:type "application" :sub-type "json" :q 0.4 :level "1"})
(parse-charset-accepted v)
Parses an accept-charset string to a list of [charset quality-score]
Parses an *accept-charset* string to a list of [*charset* *quality-score*]
(preferred-charset charsets)
Returns an acceptable choice from a list of [charset quality-score]
Returns an acceptable choice from a list of [*charset* *quality-score*]
(preferred-encoder encoders req)
Return the encoder that encodes to the most preferred type. If the Accept header of the request is a String, assume it is according to Ring spec. Else assume the header is a sequence of accepted types sorted by their preference. If no accepted encoder is found, return nil. If no Accept header is found, return the first encoder.
Return the encoder that encodes to the most preferred type. If the *Accept* header of the request is a *String*, assume it is according to Ring spec. Else assume the header is a sequence of accepted types sorted by their preference. If no accepted encoder is found, return *nil*. If no *Accept* header is found, return the first encoder.
(wrap-clojure-response handler & args)
Wrapper to serialize structures in :body to Clojure native with sane defaults.
If :hf is set to true, will use print-dup for high-fidelity
printing ( see
here ).
See wrap-format-response
for more details.
Wrapper to serialize structures in *:body* to Clojure native with sane defaults. If *:hf* is set to true, will use *print-dup* for high-fidelity printing ( see [here](https://groups.google.com/d/msg/clojure/5wRBTPNu8qo/1dJbtHX0G-IJ) ). See [[wrap-format-response]] for more details.
(wrap-format-response handler & args)
Wraps a handler such that responses body to requests are formatted to the right format. If no Accept header is found, use the first encoder.
Wraps a handler such that responses body to requests are formatted to the right format. If no *Accept* header is found, use the first encoder. + **:predicate** is a predicate taking the request and response as arguments to test if serialization should be used + **:encoders** a sequence of maps given by make-encoder + **:charset** can be either a string representing a valid charset or a fn taking the req as argument and returning a valid charset (*utf-8* is strongly suggested) + **:binary?** if true *:charset* will be ignored and decoder will receive an *InputStream* + **:handle-error** is a fn with a sig [exception request response]. Defaults to just rethrowing the Exception
(wrap-json-response handler & args)
Wrapper to serialize structures in :body to JSON with sane defaults.
See wrap-format-response
for more details.
Wrapper to serialize structures in *:body* to JSON with sane defaults. See [[wrap-format-response]] for more details.
(wrap-msgpack-response handler & args)
Wrapper to serialize structures in :body to msgpack with sane
defaults. See wrap-format-response
for more details.
Wrapper to serialize structures in *:body* to **msgpack** with sane defaults. See [[wrap-format-response]] for more details.
(wrap-restful-response handler & args)
Wrapper that tries to do the right thing with the response :body and provide a solid basis for a RESTful API. It will serialize to JSON, YAML, Clojure, Transit or HTML-wrapped YAML depending on Accept header. See wrap-format-response for more details. Recognized formats are :json, :json-kw, :edn :yaml, :yaml-in-html, :transit-json, :transit-msgpack. Options to specific encoders can be passed in using :format-options option. If is a map from format keyword to options map.
Wrapper that tries to do the right thing with the response *:body* and provide a solid basis for a RESTful API. It will serialize to JSON, YAML, Clojure, Transit or HTML-wrapped YAML depending on Accept header. See wrap-format-response for more details. Recognized formats are *:json*, *:json-kw*, *:edn* *:yaml*, *:yaml-in-html*, *:transit-json*, *:transit-msgpack*. Options to specific encoders can be passed in using *:format-options* option. If is a map from format keyword to options map.
(wrap-transit-json-response handler & args)
Wrapper to serialize structures in :body to transit over JSON with sane defaults.
See wrap-format-response
for more details.
Wrapper to serialize structures in *:body* to transit over **JSON** with sane defaults. See [[wrap-format-response]] for more details.
(wrap-transit-msgpack-response handler & args)
Wrapper to serialize structures in :body to transit over msgpack with sane defaults.
See wrap-format-response
for more details.
Wrapper to serialize structures in *:body* to transit over **msgpack** with sane defaults. See [[wrap-format-response]] for more details.
(wrap-yaml-in-html-response handler & args)
Wrapper to serialize structures in :body to YAML wrapped in HTML to
check things out in the browser. See wrap-format-response
for more
details.
Wrapper to serialize structures in *:body* to YAML wrapped in HTML to check things out in the browser. See [[wrap-format-response]] for more details.
(wrap-yaml-response handler & args)
Wrapper to serialize structures in :body to YAML with sane
defaults. See wrap-format-response
for more details.
Wrapper to serialize structures in *:body* to YAML with sane defaults. See [[wrap-format-response]] for more details.
cljdoc is a website building & hosting documentation for Clojure/Script libraries
× close