Package org.springframework.http.codec

# Interface CodecConfigurer.CustomCodecs

Enclosing interface:
  CodecConfigurer

public static interface CodecConfigurer.CustomCodecs
Registry for custom HTTP message readers and writers.

## Method Summary

Modifier and Type
Method
Description
`void`
`decoder(org.springframework.core.codec.Decoder<?> decoder)`
Deprecated.
as of 5.1.13, use `register(Object)` or `registerWithDefaultConfig(Object)` instead.
`void`
`encoder(org.springframework.core.codec.Encoder<?> encoder)`
Deprecated.
as of 5.1.13, use `register(Object)` or `registerWithDefaultConfig(Object)` instead.
`void`
`reader(HttpMessageReader<?> reader)`
Deprecated.
as of 5.1.13, use `register(Object)` or `registerWithDefaultConfig(Object)` instead.
`void`
`register(Object codec)`
Register a custom codec.
`void`
`registerWithDefaultConfig(Object codec)`
Variant of `register(Object)` that also applies the below properties, if configured, via `CodecConfigurer.defaultCodecs()`: `maxInMemorySize` `enableLoggingRequestDetails`
`void`
`registerWithDefaultConfig(Object codec, Consumer<CodecConfigurer.DefaultCodecConfig> configConsumer)`
Variant of `register(Object)` that also allows the caller to apply the properties from `CodecConfigurer.DefaultCodecConfig` to the given codec.
`void`
`withDefaultCodecConfig(Consumer<CodecConfigurer.DefaultCodecConfig> codecsConfigConsumer)`
Deprecated.
as of 5.1.13, use `registerWithDefaultConfig(Object)` or `registerWithDefaultConfig(Object, Consumer)` instead.
`void`
`writer(HttpMessageWriter<?> writer)`
Deprecated.
as of 5.1.13, use `register(Object)` or `registerWithDefaultConfig(Object)` instead.

## Method Details

### register

void register(Object codec)
Register a custom codec. This is expected to be one of the following:

- `HttpMessageReader`
- `HttpMessageWriter`
- `Encoder` (wrapped internally with `EncoderHttpMessageWriter`)
- `Decoder` (wrapped internally with `DecoderHttpMessageReader`)

Parameters:
  `codec` - the codec to register
Since:
  5.1.13

### registerWithDefaultConfig

void registerWithDefaultConfig(Object codec)
Variant of `register(Object)` that also applies the below properties, if configured, via `CodecConfigurer.defaultCodecs()`:

- `maxInMemorySize`
- `enableLoggingRequestDetails`

The properties are applied every time `CodecConfigurer.getReaders()` or `CodecConfigurer.getWriters()` are used to obtain the list of configured readers or writers.

Parameters:
  `codec` - the codec to register and apply default config to
Since:
  5.1.13

### registerWithDefaultConfig

void registerWithDefaultConfig(Object codec, Consumer<CodecConfigurer.DefaultCodecConfig> configConsumer)
Variant of `register(Object)` that also allows the caller to apply the properties from `CodecConfigurer.DefaultCodecConfig` to the given codec. If you want to apply all the properties, prefer using `registerWithDefaultConfig(Object)`.

The consumer is called every time `CodecConfigurer.getReaders()` or `CodecConfigurer.getWriters()` are used to obtain the list of configured readers or writers.

Parameters:
  `codec` - the codec to register
  `configConsumer` - consumer of the default config
Since:
  5.1.13

### decoder

@Deprecated void decoder(org.springframework.core.codec.Decoder<?> decoder)
Deprecated.
as of 5.1.13, use `register(Object)` or `registerWithDefaultConfig(Object)` instead.
Add a custom `Decoder` internally wrapped with `DecoderHttpMessageReader`).

Parameters:
  `decoder` - the decoder to add

### encoder

@Deprecated void encoder(org.springframework.core.codec.Encoder<?> encoder)
Deprecated.
as of 5.1.13, use `register(Object)` or `registerWithDefaultConfig(Object)` instead.
Add a custom `Encoder`, internally wrapped with `EncoderHttpMessageWriter`.

Parameters:
  `encoder` - the encoder to add

### reader

@Deprecated void reader(HttpMessageReader<?> reader)
Deprecated.
as of 5.1.13, use `register(Object)` or `registerWithDefaultConfig(Object)` instead.
Add a custom `HttpMessageReader`. For readers of type `DecoderHttpMessageReader` consider using the shortcut `decoder(Decoder)` instead.

Parameters:
  `reader` - the reader to add

### writer

@Deprecated void writer(HttpMessageWriter<?> writer)
Deprecated.
as of 5.1.13, use `register(Object)` or `registerWithDefaultConfig(Object)` instead.
Add a custom `HttpMessageWriter`. For writers of type `EncoderHttpMessageWriter` consider using the shortcut `encoder(Encoder)` instead.

Parameters:
  `writer` - the writer to add

### withDefaultCodecConfig

@Deprecated void withDefaultCodecConfig(Consumer<CodecConfigurer.DefaultCodecConfig> codecsConfigConsumer)
Deprecated.
as of 5.1.13, use `registerWithDefaultConfig(Object)` or `registerWithDefaultConfig(Object, Consumer)` instead.
Register a callback for the `configuration` applied to default codecs. This allows custom codecs to follow general guidelines applied to default ones, such as logging details and limiting the amount of buffered data.

Parameters:
  `codecsConfigConsumer` - the default codecs configuration callback