From e2392b36b1ca9cce596ae0e70a9497ce4a12a014 Mon Sep 17 00:00:00 2001 From: zhousheng <1413246268@qq.com> Date: Thu, 4 Feb 2021 14:56:20 +0800 Subject: [PATCH 1/2] tlog-example-gateway --- pom.xml | 1 + tlog-example-gateway/pom.xml | 50 +++++++++++++++++++ .../TlogExampleGatewayApplication.java | 18 +++++++ .../config/TLogExampleGatewayConfig.java | 31 ++++++++++++ .../src/main/resources/application.yml | 16 ++++++ 5 files changed, 116 insertions(+) create mode 100644 tlog-example-gateway/pom.xml create mode 100644 tlog-example-gateway/src/main/java/com/yomahub/tlog/example/gateway/TlogExampleGatewayApplication.java create mode 100644 tlog-example-gateway/src/main/java/com/yomahub/tlog/example/gateway/config/TLogExampleGatewayConfig.java create mode 100644 tlog-example-gateway/src/main/resources/application.yml diff --git a/pom.xml b/pom.xml index 851f1cb..f33d965 100644 --- a/pom.xml +++ b/pom.xml @@ -64,6 +64,7 @@ tlog-example-api tlog-example-eureka + tlog-example-gateway tlog-example-logback-dubbox-provider tlog-example-logback-dubbox-consumer tlog-example-logback-dubbo-provider diff --git a/tlog-example-gateway/pom.xml b/tlog-example-gateway/pom.xml new file mode 100644 index 0000000..bac5017 --- /dev/null +++ b/tlog-example-gateway/pom.xml @@ -0,0 +1,50 @@ + + + + tlog-example + com.yomahub + 1.0.0 + + 4.0.0 + tlog-example-gateway + + + 2.0.5.RELEASE + Finchley.RELEASE + + + + org.springframework.boot + spring-boot-starter + + + + org.springframework.cloud + spring-cloud-starter-gateway + + + + + org.springframework.boot + spring-boot-starter-test + test + + + + com.yomahub + tlog-all-spring-boot-starter + 1.2.3 + + + + + + + org.springframework.boot + spring-boot-maven-plugin + + + + + diff --git a/tlog-example-gateway/src/main/java/com/yomahub/tlog/example/gateway/TlogExampleGatewayApplication.java b/tlog-example-gateway/src/main/java/com/yomahub/tlog/example/gateway/TlogExampleGatewayApplication.java new file mode 100644 index 0000000..4c74150 --- /dev/null +++ b/tlog-example-gateway/src/main/java/com/yomahub/tlog/example/gateway/TlogExampleGatewayApplication.java @@ -0,0 +1,18 @@ +package com.yomahub.tlog.example.gateway; + +import com.yomahub.tlog.core.enhance.bytes.AspectLogEnhance; +import org.springframework.boot.SpringApplication; +import org.springframework.boot.autoconfigure.SpringBootApplication; + +@SpringBootApplication +public class TlogExampleGatewayApplication { + + static { + AspectLogEnhance.enhance(); + } + + public static void main(String[] args) { + SpringApplication.run(TlogExampleGatewayApplication.class, args); + } + +} diff --git a/tlog-example-gateway/src/main/java/com/yomahub/tlog/example/gateway/config/TLogExampleGatewayConfig.java b/tlog-example-gateway/src/main/java/com/yomahub/tlog/example/gateway/config/TLogExampleGatewayConfig.java new file mode 100644 index 0000000..0330d85 --- /dev/null +++ b/tlog-example-gateway/src/main/java/com/yomahub/tlog/example/gateway/config/TLogExampleGatewayConfig.java @@ -0,0 +1,31 @@ +package com.yomahub.tlog.example.gateway.config; + +import com.yomahub.tlog.core.context.AspectLogContext; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.cloud.gateway.filter.GatewayFilterChain; +import org.springframework.cloud.gateway.filter.GlobalFilter; +import org.springframework.core.Ordered; +import org.springframework.stereotype.Component; +import org.springframework.web.server.ServerWebExchange; +import reactor.core.publisher.Mono; + +/** + * @Author: zs + * @Date: 2021/2/3 15:51 + */ +@Component +public class TLogExampleGatewayConfig implements GlobalFilter, Ordered { + + private Logger log = LoggerFactory.getLogger(this.getClass()); + @Override + public Mono filter(ServerWebExchange exchange, GatewayFilterChain chain) { + log.info("gateway 拦截..."); + return chain.filter(exchange); + } + + @Override + public int getOrder() { + return 0; + } +} diff --git a/tlog-example-gateway/src/main/resources/application.yml b/tlog-example-gateway/src/main/resources/application.yml new file mode 100644 index 0000000..4fb7814 --- /dev/null +++ b/tlog-example-gateway/src/main/resources/application.yml @@ -0,0 +1,16 @@ +spring: + application: + name: tlog-example-gateway + cloud: + gateway: + routes: + - id: app1-route + #注意替换为你自己要跳转的地址 + uri: http://localhost:3111 + predicates: + - Path=/tlog/** + filters: + - StripPrefix=1 + +server: + port: 1112 -- Gitee From 9b89d526f11339651bba40d8f361fb94933c4d7e Mon Sep 17 00:00:00 2001 From: zhousheng <1413246268@qq.com> Date: Thu, 4 Feb 2021 14:58:31 +0800 Subject: [PATCH 2/2] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E7=89=88=E6=9C=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- tlog-example-gateway/pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tlog-example-gateway/pom.xml b/tlog-example-gateway/pom.xml index bac5017..9155b26 100644 --- a/tlog-example-gateway/pom.xml +++ b/tlog-example-gateway/pom.xml @@ -34,7 +34,7 @@ com.yomahub tlog-all-spring-boot-starter - 1.2.3 + 1.2.0-BETA1 -- Gitee