I've been shown how to add custom Codecs to webflux:inbound-gateway
and webflux:outbound-gateway
declarations using respectively the codec-configurer
and web-client
attributes. How to add HttpMessageWriter<> to webflux outbound-gateway
Is there a way (and perhaps even a simple way) of adding one's custom codec to the list of default codecs and hence avoid having to declare these in the endpoints?
CodePudding user response:
See CodecConfigurerFactory
. You can use a CodecConfigurer.properties
file to specify your custom strategies for those codecs:
# Default CodecConfigurer implementation classes for static Client/ServerCodecConfigurer.create() calls.
# Not meant to be customized by application developers; simply instantiate custom impl classes instead.
org.springframework.http.codec.ClientCodecConfigurer=org.springframework.http.codec.support.DefaultClientCodecConfigurer
org.springframework.http.codec.ServerCodecConfigurer=org.springframework.http.codec.support.DefaultServerCodecConfigurer