package cclotus.cloud.gateway

import com.ruoyi.common.config.RuoYiConfig
import org.springframework.context.annotation.Configuration
import org.springframework.web.reactive.config.ResourceHandlerRegistry
import org.springframework.web.reactive.config.WebFluxConfigurer

@Configuration
class WebConfig : WebFluxConfigurer {

    /**
     * 配置静态资源路径
     */
    override fun addResourceHandlers(registry: ResourceHandlerRegistry) {
        registry.addResourceHandler("$RESOURCE_PREFIX/**")
            .addResourceLocations("file:${RuoYiConfig.getProfile()}/");
        registry.addResourceHandler("/temp/**")
            .addResourceLocations("classpath:/public/temp/");
    }

    companion object {
        private const val RESOURCE_PREFIX = "/profile"
    }
}
