-
new module
muuntaja-form
to handleapplication/x-www-form-urlencoded
using ring-codec by Mathieu Lirzin -
Update deps:
[metosin/jsonista "0.2.6"] is available but we use "0.2.5"
[com.cognitect/transit-clj "1.0.324"] is available but we use "0.8.319"
- Update optional deps:
[ring/ring-codec "1.1.2"]
[cheshire "5.10.0"] is available but we use "5.9.0"
[clj-commons/clj-yaml "0.7.1"] is available but we use "0.7.0"
- Fix handler chaining when
nil
is returned from handler.
- Update deps:
[metosin/jsonista "0.2.5"] is available but we use "0.2.2"
[com.cognitect/transit-clj "0.8.319"] is available but we use "0.8.313"
- Update clj-yaml to new clj-commons fork, for Java 11 support
- new helper
m/decode-response-body
to return response body, decoded based on responseContent-Type
header. Throws if the body can't be decoded.
(-> {:headers {"accept" "application/edn"}}
((middleware/wrap-format
(constantly {:status 200, :body {:date (Date. 0)}})))
(m/decode-response-body))
; {:date #inst"1970-01-01T00:00:00.000-00:00"}
(require '[muuntaja.core :as m])
(->> {:lonely "planet"}
(m/encode "application/edn")
(m/decode "application/edn"))
; => {:lonely "planet"}
- Updated deps:
[metosin/jsonista "0.2.2"] is available but we use "0.2.1"
- Updated deps:
[cheshire "5.8.1"] is available but we use "5.8.0"
- all the changes in the 0.6.0 alphas
-
BREAKING: rewrote the interceptors
- based on the Sieppari interceptor model
- just like the middleware in
muuntaja.middleware
, butmuuntaja.interceptors
.exception-interceptor
~=wrap-exception
params-interceptor
~=wrap-params
format-interceptor
~=wrap-format
format-negotiate-interceptor
~=wrap-format-negotiate
format-request-interceptor
~=wrap-format-request
format-response-interceptor
~=wrap-format-response
-
Use
:default-charset
for response encoding if found anywhere in theaccept
header, fixes #79 -
Publish the raw content-negotiation results into
FormatAndCharset
too -
Added helpers
m/get-request-format-and-charset
andget-response-format-and-charset
(require '[muuntaja.middleware :as middleware])
(require '[muuntaja.core :as m])
(->> {:headers {"content-type" "application/edn; charset=utf-16"
"accept" "cheese/cake"
"accept-charset" "cheese-16"}}
((middleware/wrap-format identity))
((juxt m/get-request-format-and-charset
m/get-response-format-and-charset)))
;[#FormatAndCharset{:format "application/edn"
; :charset "utf-16"
; :raw-format "application/edn"}
; #FormatAndCharset{:format "application/json"
; :charset "utf-8"
; :raw-format "cheese/cake"}]
-
BREAKING: If
:body-params
is set in request, don't try to decode request body. -
BREAKING: Changes in special Muuntaja keys in request & response
:muuntaja/format
is not published into request or responsemuuntaja.core/disable-request-encoding
helper is removedmuuntaja.core/disable-response-encoding
helper is removed:muuntaja/encode?
response key (to force encoding) is renamed to:muuntaja/encode
-
BREAKING: Cheshire in dropped in favor of Jsonista as the default JSON formatter (faster, explicit configuration)
muuntaja.format.json
=>muuntaja.format.cheshire
muuntaja.format.jsonista
=>muuntaja.format.json
- The
muuntaja.format.json
formatter takes now jsonista options directly, with an asertion to fail fast if old options are used::key-fn
=>:encode-key-fn
and:decode-key-fn
:bigdecimals?
=>:bigdecimals
:mapper
option can be used to set the preconfiguredObjectMapper
.
-
move everyting from
muuntaja.records
intomuuntaja.core
-
m/slurp
to consume whatever Muuntaja can encode into a String. Not performance optimized, e.g. for testing. -
BREAKING: formats are written as Protocols instead of just functions.
- encoders should satisfy
muuntaja.format.core/EncodeToBytes
ormuuntaja.format.core/EncodeToOutputStream
- decoders should satisfy
muuntaja.format.core/Decode
- as a migration guard - if functions are used, there is an descrptive error message at Muuntaja creation time
- encoders should satisfy
-
With Muuntaja option
:return
one can control what is the encoding target. Valid values are:
value | description |
---|---|
:input-stream |
encodes into java.io.ByteArrayInputStream (default) |
:bytes |
encodes into byte[] . Faster than Stream, enables NIO for servers supporting it |
:output-stream |
encodes lazily into java.io.OutputStream via a callback function |
- Formats can override
:return
value - Formats can also have
:name
(e.g."application/json"
) and for installing new formats there ismuuntaja.core/install
- BREAKING: Muuntaja has now a multi-module layout! The modules are:
(require '[muuntaja.core :as m])
;; [metosin/muuntaja-msgpack]
(require '[muuntaja.format.msgpack])
;; [metosin/muuntaja-yaml]
(require '[muuntaja.format.yaml])
(def m (m/create
(-> m/default-options
(m/install muuntaja.format.msgpack/format)
(m/install muuntaja.format.yaml/format)
(assoc :return :bytes))))
- BREAKING:
with-streaming-***-format
helpers are removed, use:return
:output-stream
to set it. - formats can now also take
:opts
keys, which gets merged into encoder and decoder arguments and opts, so these decoders are effectively the same:
(require '[muuntaja.core :as m])
(m/decoder
(m/create
(assoc-in
m/default-options
[:formats "application/json" :opts]
{:decode-key-fn false}))
"application/json")
(m/decoder
(m/create
(assoc-in
m/default-options
[:formats "application/json" :decoder-opts]
{:decode-key-fn false}))
"application/json")
... and also this:
(require '[jsonista.core :as j])
(m/decoder
(m/create
(assoc-in
m/default-options
[:formats "application/json" :opts]
{:mapper (j/object-mapper {:decode-key-fn false})}))
"application/json")
- dropped dependencies:
[cheshire "5.8.0"]
- updated deps:
[metosin/jsonista "0.2.1"]
[com.cognitect/transit-clj "0.8.313"] is available but we use "0.8.309"
- BREAKING: rewrote the interceptors
- based on the Sieppari interceptor model
- just like the middleware in
muuntaja.middleware
, butmuuntaja.interceptors
.exception-interceptor
~=wrap-exception
params-interceptor
~=wrap-params
format-interceptor
~=wrap-format
format-negotiate-interceptor
~=wrap-format-negotiate
format-request-interceptor
~=wrap-format-request
format-response-interceptor
~=wrap-format-response
- Use
:default-charset
for response encoding if found anywhere in theaccept
header, fixes #79 - Publish the raw content-negotiation results into
FormatAndCharset
too - Removed helpers
m/get-negotiated-request-content-type
andm/get-negotiated-response-content-type
- Added helpers
m/get-request-format-and-charset
andget-response-format-and-charset
(require '[muuntaja.middleware :as middleware])
(require '[muuntaja.core :as m])
(->> {:headers {"content-type" "application/edn; charset=utf-16"
"accept" "cheese/cake"
"accept-charset" "cheese-16"}}
((middleware/wrap-format identity))
((juxt m/get-request-format-and-charset
m/get-response-format-and-charset)))
;[#FormatAndCharset{:format "application/edn"
; :charset "utf-16"
; :raw-format "application/edn"}
; #FormatAndCharset{:format "application/json"
; :charset "utf-8"
; :raw-format "cheese/cake"}]
- updated deps:
[com.cognitect/transit-clj "0.8.313"] is available but we use "0.8.309"
- If
:body-params
is set in request, don't try to decode request body.
- BREAKING: Changes in special Muuntaja keys in request & response
:muuntaja/format
is not published into request or responsemuuntaja.core/disable-request-encoding
helper is removedmuuntaja.core/disable-response-encoding
helper is removed:muuntaja/encode?
response key (to force encoding) is renamed to:muuntaja/encode
- BREAKING: if a "Content-Type" header is set in a response, the body will not be encoded, unless
:muuntaja/encode
is set
- BREAKING: Cheshire in dropped in favor of Jsonista as the default JSON formatter (faster, explicit configuration)
muuntaja.format.json
=>muuntaja.format.cheshire
muuntaja.format.jsonista
=>muuntaja.format.json
- The
muuntaja.format.json
formatter takes now jsonista options directly, with an asertion to fail fast if old options are used::key-fn
=>:encode-key-fn
and:decode-key-fn
:bigdecimals?
=>:bigdecimals
:mapper
option can be used to set the preconfiguredObjectMapper
.
- move everyting from
muuntaja.records
intomuuntaja.core
- helpers
m/get-negotiated-request-content-type
&m/get-negotiated-response-content-type
m/slurp
to consume whatever Muuntaja can encode into a String. Not performance optimized, e.g. for testing.- BREAKING: formats are written as Protocols instead of just functions.
- encoders should satisfy
muuntaja.format.core/EncodeToBytes
ormuuntaja.format.core/EncodeToOutputStream
- decoders should satisfy
muuntaja.format.core/Decode
- as a migration guard - if functions are used, there is an descrptive error message at Muuntaja creation time
- encoders should satisfy
- With Muuntaja option
:return
one can control what is the encoding target. Valid values are:
value | description |
---|---|
:input-stream |
encodes into java.io.ByteArrayInputStream (default) |
:bytes |
encodes into byte[] . Faster than Stream, enables NIO for servers supporting it |
:output-stream |
encodes lazily into java.io.OutputStream via a callback function |
- Formats can override
:return
value - Formats can also have
:name
(e.g."application/json"
) and for installing new formats there ismuuntaja.core/install
- BREAKING: Muuntaja has now a multi-module layout! The modules are:
(require '[muuntaja.core :as m])
;; [metosin/muuntaja-msgpack]
(require '[muuntaja.format.msgpack])
;; [metosin/muuntaja-yaml]
(require '[muuntaja.format.yaml])
(def m (m/create
(-> m/default-options
(m/install muuntaja.format.msgpack/format)
(m/install muuntaja.format.yaml/format)
(assoc :return :bytes))))
- BREAKING:
with-streaming-***-format
helpers are removed, use:return
:output-stream
to set it. - formats can now also take
:opts
keys, which gets merged into encoder and decoder arguments and opts, so these decoders are effectively the same:
(require '[muuntaja.core :as m])
(m/decoder
(m/create
(assoc-in
m/default-options
[:formats "application/json" :opts]
{:decode-key-fn false}))
"application/json")
(m/decoder
(m/create
(assoc-in
m/default-options
[:formats "application/json" :decoder-opts]
{:decode-key-fn false}))
"application/json")
... and also this:
(require '[jsonista.core :as j])
(m/decoder
(m/create
(assoc-in
m/default-options
[:formats "application/json" :opts]
{:mapper (j/object-mapper {:decode-key-fn false})}))
"application/json")
- dropped dependencies:
[cheshire "5.8.0"]
- added dependencies:
[metosin/jsonista "0.2.1"]
- Fix Cannot use muuntaja.core without depending on Ring.
- Re-implement
Muuntaja
as Protocol instead of Record. Fixes #59 - Optimize
UTF-8
call path with JSONISTA, 2x faster, 20-30% perf improvement with e2e JSON echo. - New helpers in
muuntaja.core
:decodes
,encodes
,matchers
,charsets
,default-charset
,default-format
,formats
andmuuntaja?
- Faster memoization cache for content negotiation
- Cleanup transitive dependencies, added:
[com.fasterxml.jackson.core/jackson-core "2.9.3"]
- Don't depend on Jackson internal Exceptions.
- Require Java 1.8 (might work on older, but tests only with 1.8
- Fixed random failures if
:allow-empty-input?
wastrue
- which was on by default.
[cheshire "5.8.0"] is available but we use "5.7.1"
- Custom Memoization Cache instead of
com.fasterxml.jackson.databind.util.LRUMap
, fixing #33.- No more direct dependency to
[Jackson Databind](https://github.com/FasterXML/jackson-databind)
- No more direct dependency to
- Unique names for Muuntaja interceptors.
-
BREAKING: Drop default support for custom encoding of records.
- Guide how to enable it in the wiki: https://github.com/metosin/muuntaja/wiki/Configuration#custom-encoding
-
BREAKING: Handling empty responses
:allow-empty-input-on-decode?
is now called:allow-empty-input?
. It's a boolean:true
(default): empty input(stream) is decoded intonil
false
with cause the decoder to do whatever it does (e.g. Transit fails, Cheshire returnsnil
)
-
BREAKING: muuntaja.json is now a separate library, jsonista
-
BREAKING: Muuntaja only supports Ring 1.6.0 or later. #47
-
jsonista decoder now allows using non-UTF charsets. #24
-
updated deps:
[cheshire "5.7.1"] is available but we use "5.7.0"
- Support Java 1.7, fixes #50
- removed direct dependencies to msgpack, fixes #39.
-
optimized
muuntaja.middleware/wrap-params
, up to 3x faster for many common cases, thanks to Dmitri Sotnikov! -
New option to allow empty input on decode,
:allow-empty-input-on-decode?
(default tofalse
). If set totrue
, empty inputstreams map tonil
body, otherwise, the decoder decides what happens (transit fails on default, cheshire does not).- Fixes #33
-
BREAKING: by default,
application/msgpack
andapplication/x-yaml
are not used (smaller core)- new helpers to add formats (need to add the deps manually):
application/yaml
:[circleci/clj-yaml "0.5.5"]
application/msgpack
:[clojure-msgpack "1.2.0" :exclusions [org.clojure/clojure]]
- new helpers to add formats (need to add the deps manually):
(require '[muuntaja.core :as m])
(require '[muuntaja.format.msgpack :as msgpack-format])
(require '[muuntaja.format.yaml :as yaml-format])
(m/create
(-> m/default-options
(yaml-format/with-yaml-format)
(msgpack-format/with-msgpack-format))
; #Muuntaja{:produces #{"application/json"
; "application/x-yaml"
; "application/msgpack"
; "application/transit+msgpack"
; "application/transit+json"
; "application/edn"},
; :consumes #{"application/json"
; "application/x-yaml"
; "application/msgpack"
; "application/transit+msgpack"
; "application/transit+json"
; "application/edn"},
; :default-charset "utf-8",
; :default-format "application/json"}
-
Alpha: The new
muuntaja.json
JSON encoder & decoder- directly on top of Jackson
- explicit mappings instead of protocol extensions
- encoding is 2.5 - 5.5x faster than Cheshire
- decoding is 30%+ faster than Cheshire
- not production ready, default JSON uses still Cheshire.
-
All middleware support now the ring-async 3-arity version:
muuntaja.middleware/wrap-exception
muuntaja.middleware/wrap-params
muuntaja.middleware/wrap-format
muuntaja.middleware/wrap-format-negotiate
muuntaja.middleware/wrap-format-request
muuntaja.middleware/wrap-format-response
-
BREAKING: move and rename http-negotiation keys from top level to
:http
in options::extract-content-type-fn
=>:extract-content-type
:extract-accept-charset-fn
=>:extract-accept-charset
:extract-accept-fn
=>:extract-accept
:decode?
=>:decode-request-body?
:encode?
=>:encode-response-body?
-
BREAKING:
muuntaja.options
namespace is thrown away.- new helpers in
muuntaja.core
:transform-formats
&select-formats
muuntaja.options/default-options-with-format-regexps
can be copy-pasted from below:
- new helpers in
(def default-options-with-format-regexps
(-> m/default-options
(assoc-in [:formats "application/json" :matches] #"^application/(.+\+)?json$")
(assoc-in [:formats "application/edn" :matches] #"^application/(vnd.+)?(x-)?(clojure|edn)$")
(assoc-in [:formats "application/msgpack" :matches] #"^application/(vnd.+)?(x-)?msgpack$")
(assoc-in [:formats "application/x-yaml" :matches] #"^(application|text)/(vnd.+)?(x-)?yaml$")
(assoc-in [:formats "application/transit+json" :matches] #"^application/(vnd.+)?(x-)?transit\+json$")
(assoc-in [:formats "application/transit+msgpack" :matches] #"^application/(vnd.+)?(x-)?transit\+msgpack$"))
-
default-options support all JVM registered charsets (instead of just
utf-8
) -
re-organized namespaces & code: formats now in separate namespaces
-
fixed Accept header parsing to allow e.g. non-numeric parameters (#67)
-
Updated deps:
[cheshire "5.7.0"] is available but we use "5.6.3"
[com.cognitect/transit-clj "0.8.300"] is available but we use "0.8.290"
[com.fasterxml.jackson.core/jackson-databind "2.8.7"] is available but we use "2.8.4"
Initial public version.