com.bybutter.sisyphus.starter.webflux.CorsConfigurationSourceRegistrar.kt Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of sisyphus-webflux-starter Show documentation
Show all versions of sisyphus-webflux-starter Show documentation
Starter for build application with String Webflux in Sisyphus Framework
package com.bybutter.sisyphus.starter.webflux
import com.bybutter.sisyphus.spring.BeanUtils
import org.springframework.beans.factory.config.ConfigurableListableBeanFactory
import org.springframework.beans.factory.support.BeanDefinitionBuilder
import org.springframework.beans.factory.support.BeanDefinitionRegistry
import org.springframework.beans.factory.support.BeanDefinitionRegistryPostProcessor
import org.springframework.web.cors.reactive.CorsConfigurationSource
import org.springframework.web.cors.reactive.CorsWebFilter
import org.springframework.web.server.WebFilter
class CorsConfigurationSourceRegistrar : BeanDefinitionRegistryPostProcessor {
override fun postProcessBeanFactory(beanFactory: ConfigurableListableBeanFactory) {
}
override fun postProcessBeanDefinitionRegistry(registry: BeanDefinitionRegistry) {
val definitionBuilder = BeanDefinitionBuilder.genericBeanDefinition(WebFilter::class.java) {
val corsConfigSource = BeanUtils.getSortedBeans(
registry as ConfigurableListableBeanFactory,
CorsConfigurationSource::class.java
).values
CorsWebFilter(DelegatingCorsConfigurationSource(corsConfigSource))
}
registry.registerBeanDefinition("corsConfiguration", definitionBuilder.beanDefinition)
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy