Spring Cloud Gateway 工作原理
客户端向 Spring Cloud Gateway 发出请求,如果请求与网关程序定义的路由匹配,则将其发送到网关 Web 处理程序,此处理程序运行特定的请求过滤器链。
过滤器之间用虚线分开的原因是过滤器可能会在发送代理请求之前或之后执行逻辑。所有 “pre” 过滤器逻辑先执行,然后执行代理请求,代理请求完成后,执行 “post” 过滤器逻辑。
如何启动 Spring Cloud Gateway
1、新建 Maven 工程,添加相关依赖 pom.xml
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.anoyi</groupId>
<artifactId>core-gateway</artifactId>
<version>0.0.1-SNAPSHOT</version>
<name>core-gateway&l