diff --git a/springcloud-service-zuul/src/main/java/com/kwan/springcloud/LogFilter.java b/springcloud-service-zuul/src/main/java/com/kwan/springcloud/LogFilter.java new file mode 100644 index 0000000000000000000000000000000000000000..6794eee207f6e338086d201bbbfbc2ef9904bd85 --- /dev/null +++ b/springcloud-service-zuul/src/main/java/com/kwan/springcloud/LogFilter.java @@ -0,0 +1,30 @@ +package com.kwan.springcloud; + +import com.netflix.zuul.ZuulFilter; +import com.netflix.zuul.exception.ZuulException; +import org.springframework.cloud.netflix.zuul.filters.support.FilterConstants; +import org.springframework.stereotype.Component; + +@Component +public class LogFilter extends ZuulFilter { + + @Override + public String filterType() { + return FilterConstants.ROUTE_TYPE; + } + + @Override + public int filterOrder() { + return FilterConstants.PRE_DECORATION_FILTER_ORDER; + } + + @Override + public boolean shouldFilter() { + return true; + } + + @Override + public Object run() throws ZuulException { + return null; + } +} \ No newline at end of file diff --git a/springcloud-service-zuul/src/main/java/com/kwan/springcloud/ZuulApplication.java b/springcloud-service-zuul/src/main/java/com/kwan/springcloud/ZuulApplication.java index 2a4feb9d81ea9e5973dcd17e774d7da15ae6d562..86c34dc8657d4be13669612f4b6c3daf06790fff 100644 --- a/springcloud-service-zuul/src/main/java/com/kwan/springcloud/ZuulApplication.java +++ b/springcloud-service-zuul/src/main/java/com/kwan/springcloud/ZuulApplication.java @@ -5,6 +5,16 @@ import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.cloud.netflix.zuul.EnableZuulProxy; + +/** + * http:/localhost:8888/portal-service/portal/1 + *

+ * http:/localhost:8888/goods-service/kwanGoodsInfo/1 + * + * @author : qinyingjie + * @version : 2.2.0 + * @date : 2023/1/16 10:02 + */ @EnableZuulProxy @SpringBootApplication public class ZuulApplication { diff --git a/springcloud-service-zuul/src/main/resources/application.yaml b/springcloud-service-zuul/src/main/resources/application.yaml index 1da6d169f1f1e9cd6dfa6fb2b5ce60c3745583e8..6cd034fce033f6d28530fe7a0836613380a163ec 100644 --- a/springcloud-service-zuul/src/main/resources/application.yaml +++ b/springcloud-service-zuul/src/main/resources/application.yaml @@ -1,36 +1,38 @@ #端口号 server: port: 8888 - spring: application: name: zuul-service #服务名称 - #路由规则: zuul: sensitiveHeaders: Cookie,Set-Cookie,Authorization routes: - api-portal: + portal: path: /portal-service/** #访问路径:http:/localhost:8888/portal-service/portal/1 - serviceId: portal-service - api-goods: - path: /goods-service/** - serviceld: goods-service - url: http://localhost:9100/,http://localhost:9200/,http://localhost:9300/ + service-id: portal-service + goods: + path: /goods-service/** #http:/localhost:8888/goods-service/kwanGoodsInfo/1 + service-id: goods-service + host: + connect-timeout-millis: 5000 #超时时间 + prefix: /api #访问路径:http:/localhost:8888/api/portal-service/portal/1 http:/localhost:8888/api/goods-service/kwanGoodsInfo/1 retryable: true - semaphore: - max-semaphores: 100 - ribbon-isolation-strategy: thread -# prefix: /api - strip-prefix: false - + ignored-services: portal-service #感略某个服务名,禁止通过该服务名访可 + # ignored-services: * #禁止通过所有的服务名访间 + ignored-patterns: /**/feign/** #不给匹配此棋式的路径进行路由·那么你到时候访间不到 + LogFilter: + route: + disable: true #用LogFilter过滤器 + # semaphore: + # max-semaphores: 100 + # ribbon-isolation-strategy: thread + # strip-prefix: false #服务提供者 eureka: client: service-url: defaultZone: http://eureka8767:8767/eureka/,http://eureka8768:8768/eureka/,http://eureka8769:8769/eureka/ - - ribbon: ConnectTimeout: 250 #连接超时时间(ms),默认值为250ms ReadTimeout: 2000 #通信超时时间(ms),默认值为2000ms