package com.kxs.gateway.api.config; import com.kxs.gateway.api.handler.ImageCodeHandler; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; import org.springframework.http.MediaType; import org.springframework.web.reactive.function.server.RequestPredicates; import org.springframework.web.reactive.function.server.RouterFunction; import org.springframework.web.reactive.function.server.RouterFunctions; import org.springframework.web.reactive.function.server.ServerResponse; /** * 验证码路由器 webflux响应式编程 * * @author 没秃顶的码农 * @date 2023/11/04 */ @Slf4j @Configuration(proxyBeanMethods = false) @RequiredArgsConstructor public class RouterFunctionConfiguration { private final ImageCodeHandler imageCodeHandler; @Bean public RouterFunction routerFunction() { return RouterFunctions.route( RequestPredicates.path("/v1/kxs/code").and(RequestPredicates.accept(MediaType.TEXT_PLAIN)), imageCodeHandler); } }