You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
39 lines
1.3 KiB
Java
39 lines
1.3 KiB
Java
|
6 years ago
|
package com.ruoyi.gateway.config;
|
||
|
|
|
||
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
||
|
|
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 com.ruoyi.gateway.handler.HystrixFallbackHandler;
|
||
|
|
import com.ruoyi.gateway.handler.ValidateCodeHandler;
|
||
|
|
|
||
|
|
/**
|
||
|
|
* 路由配置信息
|
||
|
|
*
|
||
|
|
* @author ruoyi
|
||
|
|
*/
|
||
|
|
@Configuration
|
||
|
|
public class RouterFunctionConfiguration
|
||
|
|
{
|
||
|
|
@Autowired
|
||
|
|
private HystrixFallbackHandler hystrixFallbackHandler;
|
||
|
|
|
||
|
|
@Autowired
|
||
|
|
private ValidateCodeHandler imageCodeHandler;
|
||
|
|
|
||
|
|
@SuppressWarnings("rawtypes")
|
||
|
|
@Bean
|
||
|
|
public RouterFunction routerFunction()
|
||
|
|
{
|
||
|
|
return RouterFunctions
|
||
|
|
.route(RequestPredicates.path("/fallback").and(RequestPredicates.accept(MediaType.TEXT_PLAIN)),
|
||
|
|
hystrixFallbackHandler)
|
||
|
|
.andRoute(RequestPredicates.GET("/code").and(RequestPredicates.accept(MediaType.TEXT_PLAIN)),
|
||
|
|
imageCodeHandler);
|
||
|
|
}
|
||
|
|
|
||
|
|
}
|