中文亚洲精品无码_熟女乱子伦免费_人人超碰人人爱国产_亚洲熟妇女综合网

當前位置: 首頁 > news >正文

免費中文網(wǎng)站模板html關(guān)鍵詞排名哪里查

免費中文網(wǎng)站模板html,關(guān)鍵詞排名哪里查,微商的自己做網(wǎng)站叫什么,山東城建設計院網(wǎng)站1、網(wǎng)關(guān)簡介 網(wǎng)關(guān)作為流量的入口,常用的功能包括路由轉(zhuǎn)發(fā),權(quán)限校驗,限流等。 2、Gateway簡介 Spring Cloud Gateway 是Spring Cloud官方推出的第二代網(wǎng)關(guān)框架,定位于取代 Netflix Zuul。相比 Zuul 來說,Spring Cloud Gateway 提供更優(yōu)秀的性能,更強大的有功能。 Spri…

1、網(wǎng)關(guān)簡介

網(wǎng)關(guān)作為流量的入口,常用的功能包括路由轉(zhuǎn)發(fā),權(quán)限校驗,限流等。

2、Gateway簡介

Spring Cloud Gateway 是Spring Cloud官方推出的第二代網(wǎng)關(guān)框架,定位于取代 Netflix Zuul。相比 Zuul 來說,Spring Cloud Gateway 提供更優(yōu)秀的性能,更強大的有功能。

Spring Cloud Gateway 是由 WebFlux + Netty + Reactor 實現(xiàn)的響應式的 API 網(wǎng)關(guān)。

它不能在傳統(tǒng)的 servlet 容器中工作,也不能構(gòu)建成 war 包。

Spring Cloud Gateway 旨在為微服務架構(gòu)提供一種簡單且有效的 API 路由的管理方式,并基于 Filter 的方式提供網(wǎng)關(guān)的基本功能,例如說安全認證、監(jiān)控、限流等等。

網(wǎng)文檔:https://docs.spring.io/spring-cloud-gateway/docs/current/reference/html/#gateway-starter

3、核心概念

  • 路由(route)

    路由是網(wǎng)關(guān)中最基礎的部分,路由信息包括一個ID、一個目的URI、一組謂 詞工廠、一組Filter組成。如果謂詞為真,則說明請求的URL和配置的路由匹配。

  • 謂詞(predicates)

    即java.util.function.Predicate , Spring Cloud Gateway使用Predicate實現(xiàn)路由的匹配條件。

  • 過濾器(Filter)

    SpringCloud Gateway中 的filter分為Gateway FilIer和Global Filter。Filter可以對請求和響應進行處理。

    【路由就是轉(zhuǎn)發(fā)規(guī)則,謂詞就是是否走這個路徑的條件,過濾器可以為路由添加業(yè)務邏輯,修改請求以及響應】

示例演示

spring:cloud:gateway:routes:#路由ID全局唯一- id: msb-order-route#目標微服務的請求地址和端口uri: http://localhost:8001predicates:- Path=/order/*filters:- AddRequestHeader=X-Request-Foo, Bar

這里就演示了請求 /order/*的路徑就會路由到上邊這個url上去

2、 工作原理

Spring Cloud Gateway 的工作原理跟 Zuul 的差不多,最大的區(qū)別就是 Gateway 的 Filter 只有 pre 和 post 兩種。

Spring Cloud Gateway Diagram

客戶端向 Spring Cloud Gateway 發(fā)出請求,如果請求與網(wǎng)關(guān)程序定義的路由匹配,則該請求就會被發(fā)送到網(wǎng)關(guān) Web 處理程序,此時處理程序運行特定的請求過濾器鏈。

過濾器之間用虛線分開的原因是過濾器可能會在發(fā)送代理請求的前后執(zhí)行邏輯。所有 pre 過濾器邏輯先執(zhí)行,然后執(zhí)行代理請求;代理請求完成后,執(zhí)行 post 過濾器邏輯。

4、快速入門

3.1環(huán)境搭建

引入依賴

  <!--  gateway網(wǎng)關(guān)--><dependency><groupId>org.springframework.cloud</groupId><artifactId>spring-cloud-starter-gateway</artifactId></dependency></dependencies><!--  nacos注冊中心--><dependency><groupId>com.alibaba.cloud</groupId><artifactId>spring-cloud-starter-alibaba-nacos-discovery</artifactId></dependency>

父工程的pom

<dependencies><dependency><groupId>org.springframework.boot</groupId><artifactId>spring-boot-starter-web</artifactId></dependency><dependency><groupId>com.alibaba.cloud</groupId><artifactId>spring-cloud-starter-alibaba-nacos-discovery</artifactId></dependency><dependency><groupId>org.projectlombok</groupId><artifactId>lombok</artifactId></dependency>
</dependencies>
spring:application:name: msb-gatewaycloud:nacos:discovery:server-addr: localhost:8848gateway:discovery:locator:#默認值是false,如果設為true開啟通過微服務創(chuàng)建路由的功能,即可以通過微服務名訪問服務#http://localhost:13001/msb-order/order/create#不建議打開,因為這樣暴露了服務名稱enabled: true#是否開啟網(wǎng)關(guān)enabled: true

這里注意不要引入springmvc工程否則會報錯如下:

image.png

我們工程中如下:

msb-gateway工程的pom

<dependencies><!--  gateway網(wǎng)關(guān)--><dependency><groupId>org.springframework.cloud</groupId><artifactId>spring-cloud-starter-gateway</artifactId></dependency><dependency><groupId>org.springframework.boot</groupId><artifactId>spring-boot-starter-web</artifactId><scope>test</scope> <!-- 特殊處理,不引入父工程依賴 --></dependency>
</dependencies>

3.2 測試

image.png

我們剛才說了我們不建議開啟通過微服務創(chuàng)建路由的功能,這樣就把微服務名稱暴露了,如果設置位默認值在請求一下,是否能成功呢? 我們測試一下:

image.png

是失敗的,剛才能成功主要是

http://localhost:13001/msb-order/order/create 可以進行轉(zhuǎn)化:

http://localhost:13001/msb-order/order/create可以替換為http://localhost:8001/order/create

然而此時的請求是轉(zhuǎn)化不了的

http://localhost:13001/order/create

這是我們就需要我們的gateway 中的 route& predicates 建立映射

二、路由謂詞工廠(Route Predicate Factories)配置

1、路由配置的兩種形式

1.1 路由到指定URL

  • 通配

    spring:cloud:gateway:routes:- id: {唯一標識}uri: http://localhost:8001
    

    表示訪問 GATEWAY_URL/** 會轉(zhuǎn)發(fā)到 http://localhost:8001/**

    注:上面路由的配置必須和下面謂詞(Predicate)配合使用才行

  • 精確匹配

    spring:cloud:gateway:routes:- id: {唯一標識}uri: http://localhost:8001/predicates:- Path=/order/*
    

    表示訪問 GATEWAY_URL/order/*會轉(zhuǎn)發(fā)到 http://localhost:8001/order/*

1.2 路由到服務發(fā)現(xiàn)組件上的微服務

  • 通配

    spring:cloud:gateway:routes:- id: {唯一標識}uri: lb://msb-order
    

    表示訪問 GATEWAY_URL/** 會轉(zhuǎn)發(fā)到 msb-order 微服務的 /**

    注:上面路由的配置必須和下面謂詞(Predicate)配合使用才行

  • 精確匹配

    spring:cloud:gateway:routes:- id: {唯一標識}uri: lb://msb-order/predicates:- Path=/order/*
    

    表示訪問 GATEWAY_URL/order/ 會轉(zhuǎn)發(fā)到 msb-order 微服務的 /order/

2、謂詞工廠分類

官網(wǎng):https://docs.spring.io/spring-cloud-gateway/docs/current/reference/html/#gateway-request-predicates-factories

網(wǎng)關(guān)啟動日志:

image.png

image.png

3、謂詞介紹

3.1 After路由斷言工廠

規(guī)則:

該斷言工廠的參數(shù)是一個 UTC 格式的時間。其會將請求訪問到 Gateway 的時間與該參數(shù)時間相比,若請求時間在參數(shù)時間之后,則匹配成功,斷言為 true。

配置:

spring:cloud:gateway:routes:- id: after_routeuri: lb://msb-userpredicates:# 當且僅當請求時的時間After配置的時間時,才會轉(zhuǎn)發(fā)到用戶微服務# 目前配置不會進該路由配置,所以返回404# 將時間改成 < now的時間,則訪問localhost:8040/** -> msb-user/**# eg. 訪問http://localhost:8040/users/1 -> msb-user/users/1- After=2030-01-20T17:42:47.789-07:00[America/Denver]

技巧:時間可使用 System.out.println(ZonedDateTime.now()); 打印,然后即可看到時區(qū)。例如:2019-08-10T16:50:42.579+08:00[Asia/Shanghai]

時間格式的相關(guān)邏輯:

  • 默認時間格式:org.springframework.format.support.DefaultFormattingConversionService#addDefaultFormatters
  • 時間格式注冊:org.springframework.format.datetime.standard.DateTimeFormatterRegistrar#registerFormatters

3.2 Before路由斷言工廠

規(guī)則:

該斷言工廠的參數(shù)是一個 UTC 格式的時間。其會將請求訪問到 Gateway 的時間與該參數(shù)時間相比,若請求時間在參數(shù)時間之前,則匹配成功,斷言為 true。

配置:

spring:cloud:gateway:routes:- id: before_routeuri: lb://msb-userpredicates:# 當且僅當請求時的時間Before配置的時間時,才會轉(zhuǎn)發(fā)到用戶微服務# 目前配置不會進該路由配置,所以返回404# 將時間改成 > now的時間,則訪問localhost:8040/** -> msb-user/**# eg. 訪問http://localhost:8040/users/1 -> msb-user/users/1- Before=2018-01-20T17:42:47.789-
http://www.risenshineclean.com/news/51538.html

相關(guān)文章:

  • 手機點了釣魚網(wǎng)站怎么辦查詢網(wǎng)址域名ip地址
  • 廊坊網(wǎng)站制作公司小程序開發(fā)平臺有哪些
  • 個人網(wǎng)站可以做資訊小說類網(wǎng)絡優(yōu)化工程師是做什么的
  • 2017做那個網(wǎng)站能致富惠州seo關(guān)鍵字排名
  • 做彩平的材質(zhì)網(wǎng)站優(yōu)質(zhì)友情鏈接
  • c 網(wǎng)站開發(fā)的優(yōu)點建設網(wǎng)站推廣
  • 企業(yè)網(wǎng)站建站技術(shù)seo網(wǎng)絡營銷外包公司
  • 個人建網(wǎng)站的費用百度搜索引擎官網(wǎng)入口
  • 網(wǎng)站建設南陽seo外包公司報價
  • 做網(wǎng)站客戶一般會問什么問題寧波seo外包推廣排名
  • 有哪些比較好的外貿(mào)網(wǎng)站seo推廣計劃
  • 網(wǎng)站建設企業(yè)建站要求seo的優(yōu)化原理
  • 南昌網(wǎng)站開發(fā)多少錢杭州seo公司
  • 仿xss網(wǎng)站搭建個人網(wǎng)站制作
  • 西安網(wǎng)站開發(fā)哪家好教育機構(gòu)加盟
  • 石家莊網(wǎng)站建設培訓班2022真實新聞作文400字
  • 網(wǎng)站網(wǎng)頁的收錄數(shù)量好的競價賬戶托管外包
  • 從網(wǎng)絡營銷角度做網(wǎng)站seo外包服務方案
  • 任丘網(wǎng)站優(yōu)化網(wǎng)站推廣名詞解釋
  • 免費ppt成品網(wǎng)站上海百度seo網(wǎng)站優(yōu)化
  • 北流建設局網(wǎng)站seo網(wǎng)站關(guān)鍵詞優(yōu)化工具
  • 一站式服務是什么意思網(wǎng)址和網(wǎng)站的區(qū)別
  • 上海 網(wǎng)站備案系統(tǒng)windows優(yōu)化大師會員兌換碼
  • 小程序開發(fā)費用計入什么科目seo服務商技術(shù)好的公司
  • 安康網(wǎng)站建設公司最新推廣注冊app拿傭金
  • 保健品網(wǎng)站設計短視頻營銷案例
  • 做戒指網(wǎng)站的logo照片想做個網(wǎng)絡推廣
  • 深圳做網(wǎng)站公司 南山廊坊百度推廣電話
  • 淘寶客網(wǎng)站備案信息百度指數(shù)有什么作用
  • 網(wǎng)站怎么做跳轉(zhuǎn)鏈接最近新聞今日頭條