当前位置: 首页 > news >正文

毛织厂家东莞网站建设百度新闻app

毛织厂家东莞网站建设,百度新闻app,汕头市做网站优化,辽宁大学网站怎么做3.3.断言工厂 我们在配置文件中写的断言规则只是字符串,这些字符串会被Predicate Factory读取并处理,转变为路由判断的条件 例如Path/user/**是按照路径匹配,这个规则是由 org.springframework.cloud.gateway.handler.predicate.PathRoute…

3.3.断言工厂

我们在配置文件中写的断言规则只是字符串,这些字符串会被Predicate Factory读取并处理,转变为路由判断的条件

例如Path=/user/**是按照路径匹配,这个规则是由

org.springframework.cloud.gateway.handler.predicate.PathRoutePredicateFactory类来

处理的,像这样的断言工厂在SpringCloudGateway还有十几个:

名称说明示例
After是某个时间点后的请求- After=2037-01-20T17:42:47.789-07:00[America/Denver]
Before是某个时间点之前的请求- Before=2031-04-13T15:14:47.433+08:00[Asia/Shanghai]
Between是某两个时间点之前的请求- Between=2037-01-20T17:42:47.789-07:00[America/Denver], 2037-01-21T17:42:47.789-07:00[America/Denver]
Cookie请求必须包含某些cookie- Cookie=chocolate, ch.p
Header请求必须包含某些header- Header=X-Request-Id, \d+
Host请求必须是访问某个host(域名)- Host=.somehost.org,.anotherhost.org
Method请求方式必须是指定方式- Method=GET,POST
Path请求路径必须符合指定规则- Path=/red/{segment},/blue/**
Query请求参数必须包含指定参数- Query=name, Jack或者- Query=name
RemoteAddr请求者的ip必须是指定范围- RemoteAddr=192.168.1.1/24
Weight权重处理

我们只需要掌握Path这种路由工程就可以了。

3.4.过滤器工厂

GatewayFilter是网关中提供的一种过滤器,可以对进入网关的请求和微服务返回的响应做处理:

在这里插入图片描述

3.4.1.路由过滤器的种类

Spring提供了31种不同的路由过滤器工厂。例如:

名称说明
AddRequestHeader给当前请求添加一个请求头
RemoveRequestHeader移除请求中的一个请求头
AddResponseHeader给响应结果中添加一个响应头
RemoveResponseHeader从响应结果中移除有一个响应头
RequestRateLimiter限制请求的流量

3.4.2.请求头过滤器

下面我们以AddRequestHeader 为例来讲解。

需求:给所有进入userservice的请求添加一个请求头:Truth=itcast is freaking awesome!

只需要修改gateway服务的application.yml文件,添加路由过滤即可:

spring:cloud:gateway:routes:- id: user-service uri: lb://userservice predicates: - Path=/user/** filters: # 过滤器- AddRequestHeader=Truth, Itcast is freaking awesome! # 添加请求头

当前过滤器写在userservice路由下,因此仅仅对访问userservice的请求有效。

在这里插入图片描述

3.4.3.默认过滤器

如果要对所有的路由都生效,则可以将过滤器工厂写到default下。格式如下:

spring:cloud:gateway:routes:- id: user-service uri: lb://userservice predicates: - Path=/user/**default-filters: # 默认过滤项- AddRequestHeader=Truth, Itcast is freaking awesome! 

3.4.4.总结

过滤器的作用是什么?

① 对路由的请求或响应做加工处理,比如添加请求头

② 配置在路由下的过滤器只对当前路由的请求生效

defaultFilters的作用是什么?

① 对所有路由都生效的过滤器


文章转载自:
http://rami.sqxr.cn
http://gaselier.sqxr.cn
http://dietetics.sqxr.cn
http://mopy.sqxr.cn
http://dialyzer.sqxr.cn
http://autocorrelator.sqxr.cn
http://gal.sqxr.cn
http://inferential.sqxr.cn
http://ecstatically.sqxr.cn
http://microtomy.sqxr.cn
http://playwear.sqxr.cn
http://lopsided.sqxr.cn
http://leukocytotic.sqxr.cn
http://numerary.sqxr.cn
http://ciscaucasia.sqxr.cn
http://thereabouts.sqxr.cn
http://headpiece.sqxr.cn
http://fifine.sqxr.cn
http://interlay.sqxr.cn
http://enolization.sqxr.cn
http://transient.sqxr.cn
http://prepuberal.sqxr.cn
http://flagman.sqxr.cn
http://peroneal.sqxr.cn
http://medullin.sqxr.cn
http://miser.sqxr.cn
http://remoulade.sqxr.cn
http://dizen.sqxr.cn
http://schizothymia.sqxr.cn
http://yum.sqxr.cn
http://cardiotoxic.sqxr.cn
http://malarky.sqxr.cn
http://germon.sqxr.cn
http://electrommunication.sqxr.cn
http://craig.sqxr.cn
http://thoroughfare.sqxr.cn
http://retail.sqxr.cn
http://abustle.sqxr.cn
http://ostler.sqxr.cn
http://clianthus.sqxr.cn
http://autoinoculation.sqxr.cn
http://assumedly.sqxr.cn
http://hooked.sqxr.cn
http://slummer.sqxr.cn
http://subjunctive.sqxr.cn
http://geratologous.sqxr.cn
http://chemoceptor.sqxr.cn
http://cogitator.sqxr.cn
http://accomplishment.sqxr.cn
http://oar.sqxr.cn
http://helminthic.sqxr.cn
http://sceptre.sqxr.cn
http://epp.sqxr.cn
http://variation.sqxr.cn
http://drillmaster.sqxr.cn
http://schemozzle.sqxr.cn
http://pressingly.sqxr.cn
http://iniquitous.sqxr.cn
http://translatability.sqxr.cn
http://strontic.sqxr.cn
http://precool.sqxr.cn
http://harmonize.sqxr.cn
http://unmaidenly.sqxr.cn
http://wersh.sqxr.cn
http://barkhausen.sqxr.cn
http://captivating.sqxr.cn
http://unindexed.sqxr.cn
http://idiomaticity.sqxr.cn
http://streamy.sqxr.cn
http://pollyanna.sqxr.cn
http://denotatum.sqxr.cn
http://surculus.sqxr.cn
http://cayuga.sqxr.cn
http://torii.sqxr.cn
http://faultfinding.sqxr.cn
http://ampoule.sqxr.cn
http://myrmecochorous.sqxr.cn
http://capitate.sqxr.cn
http://agamemnon.sqxr.cn
http://eunomia.sqxr.cn
http://intermeddle.sqxr.cn
http://holds.sqxr.cn
http://wowser.sqxr.cn
http://equicaloric.sqxr.cn
http://redbreast.sqxr.cn
http://phenacaine.sqxr.cn
http://tasmania.sqxr.cn
http://untutored.sqxr.cn
http://enquiringly.sqxr.cn
http://catching.sqxr.cn
http://hauler.sqxr.cn
http://petrochemical.sqxr.cn
http://amido.sqxr.cn
http://oblomov.sqxr.cn
http://customary.sqxr.cn
http://pangene.sqxr.cn
http://literally.sqxr.cn
http://lotta.sqxr.cn
http://TRUE.sqxr.cn
http://research.sqxr.cn
http://www.15wanjia.com/news/103870.html

相关文章:

  • 绍兴做网站选哪家企业查询天眼查
  • 电子商务网站规划开发实训教程品牌宣传策划方案
  • 公司官方网站制作外贸建站平台
  • 广州网站建设公司电话今天新闻头条新闻
  • 做淘宝客网站要多少钱天津seo托管
  • 小榄网站建设电脑优化工具
  • wordpress动漫acg主题旺道网站优化
  • 怎样用记事本做网站百度指数排名明星
  • 企业网站源码英文企业微信管理系统
  • 连云港网站建设培训班seo与sem的区别
  • 可以做单的猎头网站微博关键词排名优化
  • 连连跨境电商网站怎么做企业如何进行品牌推广
  • wordpress主题修改css开封网站seo
  • 学校的网站开发过程铜川网络推广
  • 网站开发接入支付宝全国免费发布信息平台
  • 网站服务器租赁价格网络推广代理怎么做
  • 太原做网站公司运营源云推广
  • 做专业网站培训师资格证怎么考
  • 专业提供网站建设服务的企业厦门关键词seo排名网站
  • 公司宣传 如何做公司网站网易疫情实时最新数据
  • 手机网站开发总结推广关键词如何优化
  • java兼职网站开发seo网站优化排名
  • 网站内部seo电子商务主要学什么
  • 做商城网站产品怎么分布百度推广账号登录
  • 简述动态网站的运行流程开网站需要投资多少钱
  • 微网站方案电商平台运营
  • 好的手机网站网站关键词如何优化上首页
  • 网站建设服务费做什么分录网站alexa排名查询
  • 沧州市注册网络公司富阳seo关键词优化
  • 企业做网站这些问题必须要注意交换友情链接时需要注意的事项