Should the documentation have an example for how to use multiple decoders?
See original GitHub issueIn my implementation I need to use the default decoder for byte[] and GsonDecoder to map to objects and I’m doing the following in Java 11:
@Bean
public Decoder decoder() {
Decoder decoder = (response, type) -> {
if (type.getTypeName().equals("java.lang.String") ||
type.getTypeName().equals("byte[]")
) {
return new Decoder.Default().decode(response, type);
} else {
return new GsonDecoder().decode(response, type);
}
};
return new ResponseEntityDecoder(decoder);
}
Is this worth having an example in the documentation? I was inspired by this discussion https://github.com/spring-cloud/spring-cloud-netflix/issues/2246
Issue Analytics
- State:
- Created 3 years ago
- Comments:7 (4 by maintainers)
Top Results From Across the Web
Encoding and Decoding Custom Types - Apple Developer
Make your data types encodable and decodable for compatibility with external representations such as JSON.
Read more >Encoder Decoder Models - Hugging Face
It is used to instantiate an Encoder Decoder model according to the specified arguments, defining the encoder and decoder configs. Configuration objects ...
Read more >codecs — Codec registry and base classes — Python 3.11.1 ...
The IncrementalDecoder class is used for decoding an input in multiple steps. It defines the following methods which every incremental decoder must define...
Read more >Decoders Syntax - Ruleset XML syntax - Wazuh documentation
A parent decoder can have many child decoders but take into account that a ... Example: Decoder_junior will enter only if decoder_parent has...
Read more >Writing a custom encoder or decoder - EasyVVUQ
For example, GenericEncoder uses text substitution in a user provided template. ... However, many large, established simulation packages have more complex ...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found

That sounds way better @velo. My scenario was the API returns
image/jpegorapplication/jsondepending on which endpoint you hit.re: wiki, no need to give me write access you can just copy/paste that gist if you want
@sshevlyagin what if we added a new
#decoder(MediaType,Decoder)toFeign.BuilderInvoking
decoder(Decoder)would overwrite the decoder as is today. Invokingdecoder(MediaType,Decoder)would replacedecoderwith aTypedDecoder, and would assign the existingdecoderto media-type*/*Subsequent invocations ofdecoder(MediaType,Decoder)would append a newDecoderto theTypedDecoder. IfMediaTypealready registered onTypedDecoderlog warning and replace.TypedDecoderwould be a implementation ofDecoderthat checks theMediaTypefirst and then delegate the decoding process toDecoder