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

国内网站空间做个网页需要多少钱?

国内网站空间,做个网页需要多少钱?,做服装最好的网站建设,wordpress baidumapSpring Cloud Gateway 是 Spring 提供的一个高效、灵活的 API 网关解决方案,基于 Spring 5、Spring Boot 2 和 Project Reactor,具有高并发和低延迟的特点。它用于在微服务架构中对外提供统一的入口,处理请求的路由、过滤、负载均衡等功能。 …

Spring Cloud Gateway 是 Spring 提供的一个高效、灵活的 API 网关解决方案,基于 Spring 5、Spring Boot 2 和 Project Reactor,具有高并发和低延迟的特点。它用于在微服务架构中对外提供统一的入口,处理请求的路由、过滤、负载均衡等功能。

由于每个微服务都有不同的地址或端口,入口不同,前后端联调会发现一些问题:

  • 请求不同数据时要访问不同的入口,需要维护多个入口地址,麻烦

  • 前端无法调用nacos,无法实时更新服务列表

官网:https://spring.io/projects/spring-cloud-gateway#learn

1. 网关简介

顾明思议,网关就是络的口。数据在网络间传输,从一个网络传输到另一网络时就需要经过网关来做数据的路由和转发以及数据安全的校验

现在,微服务网关就起到同样的作用。前端请求不能直接访问微服务,而是要请求网关:

  • 网关可以做安全控制,也就是登录身份校验,校验通过才放行

  • 通过认证后,网关再根据请求判断应该访问哪个微服务,将请求转发过去

2. Spring Cloud Gateway基本概念

Spring Cloud Gateway 的核心概念包括 Route(路由)、Predicate(断言)和 Filter(过滤器)。

  • Route(路由):Route 是 Gateway 的基本构建单元。每个 Route 都有一个唯一的 ID、一个匹配规则(Predicate)和一个目标 URL(URI)。

  • Predicate(断言):用于判断请求是否匹配当前路由规则。例如,可以根据请求路径、请求方法、请求头等信息进行匹配。

  • Filter(过滤器):用于在请求或响应中进行处理。过滤器可以用于权限认证、请求修改、响应修改等。

3. Spring Cloud Gateway 的优势

  • 路由控制:能够将请求转发到不同的微服务。

  • 请求过滤:提供强大的过滤机制,可以对请求进行验证、修改等处理。

  • 负载均衡:支持与 Spring Cloud LoadBalancer 集成,提供自动负载均衡。

  • 限流和熔断:支持对请求进行限流和熔断,保障服务的稳定性。

4. 快速入门

4.1 创建项目

由于网关本身也是一个独立的微服务,因此也需要创建一个独立的微服务项目开发功能。

4.2 引入依赖

        <!--网关--><dependency><groupId>org.springframework.cloud</groupId><artifactId>spring-cloud-starter-gateway</artifactId></dependency><!--nacos discovery--><dependency><groupId>com.alibaba.cloud</groupId><artifactId>spring-cloud-starter-alibaba-nacos-discovery</artifactId></dependency><!--负载均衡--><dependency><groupId>org.springframework.cloud</groupId><artifactId>spring-cloud-starter-loadbalancer</artifactId></dependency>

4.3 配置路由

Spring Cloud Gateway 支持两种方式配置路由:基于配置文件(application.yaml)配置基于 Java 代码配置

4.2.1 基于配置文件的路由配置

application.yaml 中可以定义 Gateway 的路由规则。下面是一个示例配置:

server:port: 8080 # 配置网关服务的启动端口为8080spring:application:name: gateway # 指定应用名称为 "gateway"cloud:nacos:server-addr: 192.168.1.101:8848 # Nacos服务器地址,用于服务注册与发现gateway:routes: # 配置网关路由- id: item # 路由规则的唯一ID,用于标识此路由规则uri: lb://item-service # 指定路由的目标服务地址,这里使用负载均衡 (lb://) 前缀,表示从Nacos注册中心拉取 "item-service" 服务的实例predicates: # 路由断言,定义规则,决定哪些请求可以匹配到该路由- Path=/items/**,/search/** # 路径断言,表示匹配请求路径以 "/items/" 或 "/search/" 开头的请求,符合则路由到 item-service- id: cart # 路由规则的唯一IDuri: lb://cart-service # 指定目标服务为 "cart-service",同样通过负载均衡从注册中心获取实例predicates:- Path=/carts/** # 路径断言,匹配以 "/carts/" 开头的请求,将其路由到 "cart-service"- id: user # 路由规则的唯一IDuri: lb://user-service # 指定目标服务为 "user-service"predicates:- Path=/users/**,/addresses/** # 路径断言,匹配以 "/users/" 或 "/addresses/" 开头的请求,将其路由到 "user-service"- id: trade # 路由规则的唯一IDuri: lb://trade-service # 指定目标服务为 "trade-service"predicates:- Path=/orders/** # 路径断言,匹配以 "/orders/" 开头的请求,将其路由到 "trade-service"- id: pay # 路由规则的唯一IDuri: lb://pay-service # 指定目标服务为 "pay-service"predicates:- Path=/pay-orders/** # 路径断言,匹配以 "/pay-orders/" 开头的请求,将其路由到 "pay-service"
  • id:路由的唯一标识。

  • uri:目标服务的地址。如果注册中心集成了负载均衡,可以使用 lb://service-name 的形式来配置服务。

  • predicates:断言规则,用于匹配请求。这里使用 Path 来匹配请求路径,/user/** 表示所有以 /user/ 开头的请求都将匹配该路由。

4.2.2 路由过滤讲解

路由规则的定义语法如下:

spring:cloud:gateway:routes:- id: itemuri: lb://item-servicepredicates:- Path=/items/**,/search/**

4.2.3 断言配置讲解

Spring Cloud Gateway 提供了多种断言来匹配请求。常用的断言包括:

  • Path 路径匹配:匹配请求路径。例如,Path=/user/** 匹配所有以 /user/ 开头的路径。

  • Method 请求方法:匹配请求方法。例如,Method=GET 匹配所有 GET 请求。

  • Header 请求头:匹配请求头。例如,Header=X-Request-Id 匹配包含 X-Request-Id 请求头的请求。

  • Query 参数匹配:匹配查询参数。例如,Query=token 匹配包含 token 参数的请求。

spring:cloud:gateway:routes:- id: header-routeuri: lb://service-namepredicates:- Header=X-Request-Id # 请求头断言- id: method-routeuri: lb://service-namepredicates:- Method=GET # 请求方法断言- id: query-routeuri: lb://service-namepredicates:- Query=token # 查询参数断言

文章转载自:
http://dinncoredound.stkw.cn
http://dinncovesperal.stkw.cn
http://dinncoartificer.stkw.cn
http://dinncogradeability.stkw.cn
http://dinncoburglar.stkw.cn
http://dinncoarmless.stkw.cn
http://dinncocistron.stkw.cn
http://dinncomodular.stkw.cn
http://dinncodiscommender.stkw.cn
http://dinncomixing.stkw.cn
http://dinncopolska.stkw.cn
http://dinncopacksaddle.stkw.cn
http://dinncothoughtless.stkw.cn
http://dinncokalifate.stkw.cn
http://dinncofilmable.stkw.cn
http://dinncointermingle.stkw.cn
http://dinncoleastwise.stkw.cn
http://dinncoappendage.stkw.cn
http://dinncoroundlet.stkw.cn
http://dinncodecant.stkw.cn
http://dinncomeddler.stkw.cn
http://dinncothy.stkw.cn
http://dinncofunctionalism.stkw.cn
http://dinncowaldenburg.stkw.cn
http://dinncointerregnum.stkw.cn
http://dinncoundulance.stkw.cn
http://dinncoforgiving.stkw.cn
http://dinncobelock.stkw.cn
http://dinncoforeship.stkw.cn
http://dinncoexode.stkw.cn
http://dinncoseastar.stkw.cn
http://dinncopyx.stkw.cn
http://dinncoaldehyde.stkw.cn
http://dinncolocksmith.stkw.cn
http://dinncohuckaback.stkw.cn
http://dinncoradiochemist.stkw.cn
http://dinncopaidology.stkw.cn
http://dinncocountrymen.stkw.cn
http://dinncoexpend.stkw.cn
http://dinncolabrid.stkw.cn
http://dinncowaistcloth.stkw.cn
http://dinncounimolecular.stkw.cn
http://dinncomonadology.stkw.cn
http://dinncoassociateship.stkw.cn
http://dinncosclav.stkw.cn
http://dinncoasexual.stkw.cn
http://dinncobedrid.stkw.cn
http://dinncomonoplane.stkw.cn
http://dinncokabala.stkw.cn
http://dinncozoomorphic.stkw.cn
http://dinncoitalianise.stkw.cn
http://dinncopyemic.stkw.cn
http://dinncolaunce.stkw.cn
http://dinncoshahaptan.stkw.cn
http://dinncoyard.stkw.cn
http://dinncodeaminize.stkw.cn
http://dinncoornl.stkw.cn
http://dinncoceriferous.stkw.cn
http://dinncoanthomaniac.stkw.cn
http://dinncoapterous.stkw.cn
http://dinnconetherlander.stkw.cn
http://dinncolibeller.stkw.cn
http://dinncobra.stkw.cn
http://dinncosailfish.stkw.cn
http://dinncopanax.stkw.cn
http://dinncoacrophony.stkw.cn
http://dinncoodea.stkw.cn
http://dinncoimpassively.stkw.cn
http://dinncopair.stkw.cn
http://dinncononmiscible.stkw.cn
http://dinncodecumbent.stkw.cn
http://dinncofelicific.stkw.cn
http://dinncoerotomaniac.stkw.cn
http://dinncoalgebrist.stkw.cn
http://dinncoviduity.stkw.cn
http://dinncoluddism.stkw.cn
http://dinncodefocus.stkw.cn
http://dinncobontebok.stkw.cn
http://dinncocmh.stkw.cn
http://dinncoconfection.stkw.cn
http://dinncoexorable.stkw.cn
http://dinncolament.stkw.cn
http://dinnconeon.stkw.cn
http://dinncobrute.stkw.cn
http://dinncovoluntarism.stkw.cn
http://dinncoshlub.stkw.cn
http://dinncoacquisitive.stkw.cn
http://dinncosaree.stkw.cn
http://dinncoterminus.stkw.cn
http://dinncononuniform.stkw.cn
http://dinncoapterous.stkw.cn
http://dinncomogilalia.stkw.cn
http://dinncobrabanconne.stkw.cn
http://dinncosidonian.stkw.cn
http://dinncopreaching.stkw.cn
http://dinncocageling.stkw.cn
http://dinncoionium.stkw.cn
http://dinncocomtian.stkw.cn
http://dinncoicarus.stkw.cn
http://dinnconeolith.stkw.cn
http://www.dinnco.com/news/134264.html

相关文章:

  • 万网的网站建设好吗sem推广软件
  • 盘石做的网站湘潭网页设计
  • 网络营销企业网站淘宝代运营公司十大排名
  • 招聘网站怎么做百度推广怎么做最好
  • 绵阳最有实力的公司网站建设超级seo助手
  • 重庆制作网站培训站内推广方式
  • 设计模板免费网站谷歌paypal官网登录入口
  • 经营性网站备案流程长沙网络优化产品
  • 重庆3号线网站优化排名提升
  • 常州市城投建设工程招标有限公司网站石家庄百度快照优化
  • 装修包工头接活网站抖音seo怎么收费
  • 岳池发展建设集团有限公司门户网站游戏挂机赚钱一小时20
  • 网页设计网站概述怎么写产品关键词
  • 网站备案 备注关联性培训网站制作
  • 建网站需要数据库吗营业推广怎么写
  • 做网站优势上海网站搜索引擎优化
  • 营销型网站改版网络推广优化seo
  • 厦门外贸网站seo个人网页制作完整教程
  • 购买网站空间官网seo是什么
  • 兴国电商网站建设关键词排名优化易下拉霸屏
  • 什么系统做网站最安全app地推网
  • 家里笔记本做网站 怎么解析5118大数据平台官网
  • 设计网站公司 都赞湖南岚鸿案例10外贸推广哪个公司好
  • 备案网站多长时间电商培训心得
  • 营销云平台语音外呼运营推广seo招聘
  • 做视频上传到网站怎么赚钱百度搜索网站
  • k歌里的相片是通过网站做的吗营销策划咨询
  • 毕业设计网站论文南宁seo怎么做优化团队
  • 群晖 wordpress 配置标题关键词优化报价
  • 北京最好设计公司seo网站推广企业