All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.bybutter.sisyphus.starter.jackson.yaml.Jackson2YamlCodecCustomizer.kt Maven / Gradle / Ivy

There is a newer version: 2.1.22
Show newest version
package com.bybutter.sisyphus.starter.jackson.yaml

import com.bybutter.sisyphus.jackson.Yaml
import org.springframework.boot.web.codec.CodecCustomizer
import org.springframework.http.codec.CodecConfigurer
import org.springframework.util.MimeType

class Jackson2YamlCodecCustomizer : CodecCustomizer {
    companion object {
        val DEFAULT_YAML_MIME_TYPES = arrayOf(
            MimeType("text", "vnd.yaml"),
            MimeType("text", "yaml"),
            MimeType("text", "x-yaml"),
            MimeType("text", "*+x-yaml"),
            MimeType("application", "yaml"),
            MimeType("application", "x-yaml"),
            MimeType("application", "*+x-yaml")
        )
    }

    override fun customize(configurer: CodecConfigurer) {
        configurer.customCodecs().register(Jackson2YamlEncoder(Yaml.mapper, *DEFAULT_YAML_MIME_TYPES))
        configurer.customCodecs().register(Jackson2YamlDecoder(Yaml.mapper, *DEFAULT_YAML_MIME_TYPES))
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy