Class CodecRegistry.Builder

    • Nested Class Summary

      Nested Classes 
      Modifier and Type Class Description
    • Field Summary

      Fields 
      Modifier and Type Field Description
    • Enum Constant Summary

      Enum Constants 
      Enum Constant Description
    • Method Summary

      Modifier and Type Method Description
      final Unit defaultContentType(String contentType) Set the default content type for auto-selection
      final <T extends Any> Unit registerJson(KClass<T> type, KSerializer<T> serializer) Register a JSON codec for a specific type using kotlinx.
      final <T extends Any> Unit register(KClass<T> type, MessageCodec<T> codec) Register a custom codec
      final CodecRegistry.Builder configureJson(Function1<JsonBuilder, Unit> block) Adjust the Json instance that backs every JSON codecThe block starts from the registry's defaults (lenient, unknown keys ignored, defaults not encoded) and changes only what it names:
      codecs {
          configureJson { explicitNulls = false }
          registerJson(OrderEvent::class, OrderEvent.serializer())
      }
      A codec captures the configuration when it is registered, so this has to come first.
      final CodecRegistry build() Build the registryString and ByteArray are always served, whether or not anything was registered, so text and raw payloads need no ceremony.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • CodecRegistry.Builder

        CodecRegistry.Builder()
    • Method Detail

      • registerJson

         final <T extends Any> Unit registerJson(KClass<T> type, KSerializer<T> serializer)

        Register a JSON codec for a specific type using kotlinx.serialization

      • configureJson

         final CodecRegistry.Builder configureJson(Function1<JsonBuilder, Unit> block)

        Adjust the Json instance that backs every JSON codec

        The block starts from the registry's defaults (lenient, unknown keys ignored, defaults not encoded) and changes only what it names:

        codecs {
            configureJson { explicitNulls = false }
            registerJson(OrderEvent::class, OrderEvent.serializer())
        }

        A codec captures the configuration when it is registered, so this has to come first. Calling it after a registerJson fails loudly rather than leaving that codec behind on the previous configuration.

      • build

         final CodecRegistry build()

        Build the registry

        String and ByteArray are always served, whether or not anything was registered, so text and raw payloads need no ceremony. An explicit registration for either type wins.