2021-04-19 23:37:33 +08:00
|
|
|
|
package ink.wgink.gateway.router;
|
|
|
|
|
|
|
|
|
|
import ink.wgink.gateway.handler.route.RouteHandler;
|
|
|
|
|
import org.springframework.context.annotation.Bean;
|
|
|
|
|
import org.springframework.stereotype.Component;
|
2021-04-20 12:32:15 +08:00
|
|
|
|
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;
|
2021-04-19 23:37:33 +08:00
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* When you feel like quitting. Think about why you started
|
|
|
|
|
* 当你想要放弃的时候,想想当初你为何开始
|
|
|
|
|
*
|
2021-04-20 12:32:15 +08:00
|
|
|
|
* @ClassName: RouteRouter
|
|
|
|
|
* @Description: 路由管理
|
|
|
|
|
* @Author: wanggeng
|
|
|
|
|
* @Date: 2021/4/20 10:19 上午
|
2021-04-19 23:37:33 +08:00
|
|
|
|
* @Version: 1.0
|
2021-04-20 12:32:15 +08:00
|
|
|
|
*/
|
2021-04-19 23:37:33 +08:00
|
|
|
|
@Component
|
2021-04-20 12:32:15 +08:00
|
|
|
|
public class RouteRouter {
|
2021-04-19 23:37:33 +08:00
|
|
|
|
/**
|
|
|
|
|
* 路由管理
|
|
|
|
|
*
|
|
|
|
|
* @param routeHandler
|
|
|
|
|
* @return
|
|
|
|
|
*/
|
|
|
|
|
@Bean
|
2021-04-20 12:32:15 +08:00
|
|
|
|
public RouterFunction<ServerResponse> routeRouterFunction(RouteHandler routeHandler) {
|
2021-04-19 23:37:33 +08:00
|
|
|
|
// 嵌套
|
2021-04-20 12:32:15 +08:00
|
|
|
|
return RouterFunctions.nest(RequestPredicates.path("/wg/route"),
|
2021-04-19 23:37:33 +08:00
|
|
|
|
RouterFunctions
|
|
|
|
|
.route(RequestPredicates.POST("/save"), routeHandler::save)
|
|
|
|
|
.andRoute(RequestPredicates.DELETE("/delete/{ids}"), routeHandler::delete)
|
|
|
|
|
.andRoute(RequestPredicates.PUT("/update/{id}"), routeHandler::update)
|
|
|
|
|
.andRoute(RequestPredicates.GET("/list"), routeHandler::list)
|
2021-04-20 12:32:15 +08:00
|
|
|
|
.andRoute(RequestPredicates.GET("/listpage"), routeHandler::listPage)
|
2021-04-19 23:37:33 +08:00
|
|
|
|
.andRoute(RequestPredicates.GET("get/{id}"), routeHandler::get)
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|