Set of recognised charsets by the current JVM
Set of recognised charsets by the current JVM
(default-handle-error e _ _)
Default error handling function used, which rethrows the Exception
Default error handling function used, which rethrows the Exception
(get-or-guess-charset req)
Tries to get the request encoding from the header or guess it if not given in Content-Type. Defaults to utf-8
Tries to get the request encoding from the header or guess it if not given in *Content-Type*. Defaults to *utf-8*
(make-type-request-pred regexp)
Function that returns a predicate fn checking if Content-Type request header matches a specified regexp and body is set.
Function that returns a predicate fn checking if *Content-Type* request header matches a specified regexp and body is set.
(parse-clojure-string s)
Decode a clojure body. The body is merged into the params, so must be a map or a vector of key value pairs. An empty body is safely handled.
Decode a clojure body. The body is merged into the params, so must be a map or a vector of key value pairs. An empty body is safely handled.
(wrap-clojure-params handler
&
[{:keys [predicate decoder charset handle-error]
:or {predicate clojure-request?
decoder parse-clojure-string
charset get-or-guess-charset
handle-error default-handle-error}}])
Handles body params in Clojure (edn) format. See wrap-format-params
for details.
Handles body params in Clojure (*edn*) format. See [[wrap-format-params]] for details.
(wrap-format-params handler
&
[{:keys [predicate decoder charset handle-error binary?]}])
Wraps a handler such that requests body are deserialized from to the right format, added in a :body-params key and merged in :params. It takes 4 args:
Wraps a handler such that requests body are deserialized from to the right format, added in a *:body-params* key and merged in *:params*. It takes 4 args: + **:predicate** is a predicate taking the request as sole argument to test if deserialization should be used. + **:decoder** specifies a fn taking the body String as sole argument and giving back a hash-map. + **:charset** can be either a string representing a valid charset or a fn taking the req as argument and returning a valid charset. + **:binary?** if true *:charset* will be ignored and decoder will receive an *InputStream* + **:handle-error** is a fn with a sig [exception handler request]. Return (handler obj) to continue executing a modified request or directly a map to answer immediately. Defaults to just rethrowing the Exception
(wrap-json-kw-params handler
&
[{:keys [predicate decoder charset handle-error]
:or {predicate json-request?
decoder json/parse-string
charset get-or-guess-charset
handle-error default-handle-error}}])
Handles body params in JSON format. Parses map keys as keywords.
See wrap-format-params
for details.
Handles body params in JSON format. Parses map keys as keywords. See [[wrap-format-params]] for details.
(wrap-json-params handler
&
[{:keys [predicate decoder charset handle-error]
:or {predicate json-request?
decoder json/parse-string
charset get-or-guess-charset
handle-error default-handle-error}}])
Handles body params in JSON format. See wrap-format-params
for details.
Handles body params in JSON format. See [[wrap-format-params]] for details.
(wrap-restful-params handler
&
[{:keys [handle-error formats]
:or {handle-error default-handle-error
formats [:json :edn :yaml :transit-msgpack
:transit-json]}
:as opts}])
Wrapper that tries to do the right thing with the request :body and provide
a solid basis for a RESTful API. It will deserialize to JSON, YAML, Transit
or Clojure depending on Content-Type header. See wrap-format-params
for
more details.
Wrapper that tries to do the right thing with the request :body and provide a solid basis for a RESTful API. It will deserialize to *JSON*, *YAML*, *Transit* or *Clojure* depending on Content-Type header. See [[wrap-format-params]] for more details.
(wrap-transit-json-params handler
&
[{:keys [predicate decoder charset binary?
handle-error options]
:or {predicate transit-json-request?
options {}
binary? true
handle-error default-handle-error}}])
Handles body params in transit format over JSON. You can use an :options key to pass
a map with :handlers and :default-handler to transit-clj. See wrap-format-params
for details.
Handles body params in transit format over **JSON**. You can use an *:options* key to pass a map with *:handlers* and *:default-handler* to transit-clj. See [[wrap-format-params]] for details.
(wrap-transit-msgpack-params handler
&
[{:keys [predicate decoder charset binary?
handle-error options]
:or {predicate transit-msgpack-request?
options {}
binary? true
handle-error default-handle-error}}])
Handles body params in transit format over msgpack. You can use an :options key to pass
a map with :handlers and :default-handler to transit-clj. See wrap-format-params
for details.
Handles body params in transit format over **msgpack**. You can use an *:options* key to pass a map with *:handlers* and *:default-handler* to transit-clj. See [[wrap-format-params]] for details.
(wrap-yaml-kw-params handler
&
[{:keys [predicate decoder charset handle-error]
:or {predicate yaml-request?
decoder yaml/parse-string
charset get-or-guess-charset
handle-error default-handle-error}}])
Handles body params in YAML format. Parses map keys as keywords.
See wrap-format-params
for details.
Handles body params in YAML format. Parses map keys as keywords. See [[wrap-format-params]] for details.
(wrap-yaml-params handler
&
[{:keys [predicate decoder charset handle-error]
:or {predicate yaml-request?
decoder yaml/parse-string
charset get-or-guess-charset
handle-error default-handle-error}}])
Handles body params in YAML format. See wrap-format-params
for details.
Handles body params in YAML format. See [[wrap-format-params]] for details.
cljdoc is a website building & hosting documentation for Clojure/Script libraries
× close