diff --git a/pom.xml b/pom.xml index 851f1cb1fa86090e80c855efa4efe58633923e81..f33d96503602b4e4310a13d07ba788fa58ee46a9 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 0000000000000000000000000000000000000000..9155b263614cfa3dc04b639e6d12ed2cbb1554fc --- /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.0-BETA1 + + + + + + + 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 0000000000000000000000000000000000000000..4c7415069b67b700ca562a99cc6313469efab53d --- /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 0000000000000000000000000000000000000000..0330d85bfb10fc401ab726a4dd47b9e8607b0399 --- /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 0000000000000000000000000000000000000000..4fb781491f449f6b9b999b4b8a8ac64ad4586bb6 --- /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