From f32eccd4924a186ec650fd9096ec81bc9a618e0a Mon Sep 17 00:00:00 2001 From: tanghc Date: Thu, 4 Mar 2021 10:03:56 +0800 Subject: [PATCH] 4.3.0 --- .../controller/FilterPrintController.java | 58 ------------------- 1 file changed, 58 deletions(-) delete mode 100644 sop-common/sop-gateway-common/src/main/java/com/gitee/sop/gatewaycommon/gateway/controller/FilterPrintController.java diff --git a/sop-common/sop-gateway-common/src/main/java/com/gitee/sop/gatewaycommon/gateway/controller/FilterPrintController.java b/sop-common/sop-gateway-common/src/main/java/com/gitee/sop/gatewaycommon/gateway/controller/FilterPrintController.java deleted file mode 100644 index 4ac3969b..00000000 --- a/sop-common/sop-gateway-common/src/main/java/com/gitee/sop/gatewaycommon/gateway/controller/FilterPrintController.java +++ /dev/null @@ -1,58 +0,0 @@ -package com.gitee.sop.gatewaycommon.gateway.controller; - -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.cloud.gateway.filter.GlobalFilter; -import org.springframework.context.ApplicationContext; -import org.springframework.core.Ordered; -import org.springframework.http.ResponseEntity; -import org.springframework.stereotype.Controller; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.server.ServerWebExchange; -import reactor.core.publisher.Mono; - -import java.util.Comparator; -import java.util.List; -import java.util.Map; -import java.util.stream.Collectors; - -/** - * @author tanghc - */ -@Controller -public class FilterPrintController { - - @Autowired - private ApplicationContext applicationContext; - - @RequestMapping("sop/listGlobalFilters") - public Mono> listGlobalFilters(ServerWebExchange exchange) { - Map filterMap = applicationContext.getBeansOfType(GlobalFilter.class); - List filters = filterMap.values() - .stream() - .sorted(new Comparator() { - @Override - public int compare(GlobalFilter o1, GlobalFilter o2) { - if (o1 instanceof Ordered && o2 instanceof Ordered) { - Ordered order1 = (Ordered) o1; - Ordered order2 = (Ordered) o2; - return Integer.compare(order1.getOrder(), order2.getOrder()); - } - return 0; - } - }) - .map(globalFilter -> { - int order = 0; - if (globalFilter instanceof Ordered) { - Ordered ordered = (Ordered) globalFilter; - order = ordered.getOrder(); - } - return order + ", " + globalFilter.getClass().getSimpleName(); - }) - .collect(Collectors.toList()); - - String result = String.join("
", filters); - return Mono.just(ResponseEntity.ok(result)); - } - - -}