一 源码位置

https://github.com/cakin24/spring-cloud-code/tree/master/ch17-2/ch17-2-9-gateway

二 关键代码

package cn.springcloud.book.gateway;import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.gateway.route.RouteLocator;
import org.springframework.cloud.gateway.route.builder.RouteLocatorBuilder;
import org.springframework.context.annotation.Bean;@SpringBootApplication
public class SpringCloudGatewayApplication {@Beanpublic RouteLocator customRouteLocator(RouteLocatorBuilder builder) {// 关键是下面几行代码return builder.routes().route("remoteaddr_route", r -> r.remoteAddr("127.0.0.1").uri("http://baidu.com")).build();}public static void main(String[] args) {SpringApplication.run(SpringCloudGatewayApplication.class, args);}
}

三 测试

1 启动ch17-2-9-gateway

2 浏览器输入:http://127.0.0.1:8080

3 跳转到百度主页,测试成功!

Spring Cloud Gateway路由断言实战——RemoteAddr路由断言工厂相关推荐

  1. Spring Cloud Gateway(十):网关过滤器工厂 GatewayFilterFactory

    本文基于 spring cloud gateway 2.0.1 1.GatewayFilterFactory 简介 路由过滤器允许以某种方式修改传入的HTTP请求或传出的HTTP响应. 路径过滤器的范 ...

  2. Spring Cloud Gateway(五):路由定位器 RouteLocator

    本文基于 spring cloud gateway 2.0.1 1.简介 直接 获取 路 由 的 方法 是 通过 RouteLocator 接口 获取. 同样, 该 顶 级 接口 有多 个 实现 类, ...

  3. Spring Cloud Gateway源码系列之路由配置加载过程

    当前章节主要是讲解配置文件中定义的路由配置被gateway加载,同时转为可以直接操作的路由对象 引入pom坐标 <dependency><groupId>org.springf ...

  4. Spring Cloud Gateway整合Nacos实现服务路由及集群负载均衡

    目录 一.序言 二.代码示例 1.父工程spring-cloud-gateway-learning 2.子工程spring-cloud-api-gateway (1) pom.xml (2) 配置文件 ...

  5. Spring cloud Gateway 服务网关 实战

    Spring cloud Gateway 服务网关 一.简介 优点: 特性: 总结: 二.核心概念 三.路由规则 1.Path 2.Query 3.Method 4.Datetime 5.Romote ...

  6. Spring Cloud Gateway 替换 Nginx 实战

    一 搭建 server-dataway 微服务 二 引入 pom文件 <?xml version="1.0" encoding="UTF-8"?> ...

  7. 三分钟了解Spring Cloud Gateway路由转发之自动路由

    文章目录 一.前言 二.路由配置 1. 静态路由 2. 动态路由 3. 自动路由 三.Spring Cloud Gateway 是如何实现动态路由 工作原理 源码解析 路由转发原理 路由转发源码解析 ...

  8. 【项目实战】Spring Cloud Gateway入门介绍 - 网关过滤器工厂

    一.全局过滤器GlobalFilter 全局过滤器是针对于网关而言通用的功能组件实现,采用全局来实现. 以下是两个如何全局过滤器GlobalFilter的实例 1.1 实例1:定义ForwardAut ...

  9. 网关Spring Cloud Gateway科普

    点击上方"朱小厮的博客",选择"设为星标" 后台回复"加群"获取公众号专属群聊入口 欢迎跳转到本文的原文链接:https://honeypp ...

最新文章

  1. 【 Vivado 】时钟类型
  2. pthread_cleanup_push
  3. 一种求任意多边形内部水平方向似最大矩形的算法
  4. 成功解决 AttributeError: module 'tensorflow' has no attribute 'sub'
  5. html5 文件转byte[],JS 文件base64、File、Blob、ArrayBuffer互转
  6. java自动gc_具有Java 7中自动资源管理功能的GC
  7. Uboot 命令是如何被使用的?
  8. layui表单加文件 php_layui框架实现文件上传及TP3.2.3(thinkPHP)对上传文件进行后台处理操作示例...
  9. 我的世界java导出皮肤_我的世界Alex1.8夕立poi皮肤
  10. 小程序影藏溢出的gif_Win10即将推出GIF录制编辑工具,不再需要第三方软件了
  11. 3.4 主存储器与CPU的连接———存储器容量的扩充
  12. 靶机渗透练习Vulnhub DriftingBlues-6
  13. Twaver-HTML5基础学习(26)背景
  14. Windows cmd常用命令
  15. 网页换肤,模块换肤,jQuery的Cookie插件使用(转)
  16. 微信公众号模板消息管理
  17. 北邮 计算机网络实验二
  18. Docker--10张图带你深入理解Docker容器和镜像
  19. 用python给女朋友惊喜_怎样用Python讨您的女朋友欢心(附源码)?女孩很好哄的嘛! zt...
  20. H5怎么制作?快来看这个H5制作平台的案例你可能就明白了

热门文章

  1. HTML Imports
  2. 2021计算机行业还有前途吗?从业十二年的程序员告诉你优缺!
  3. Leetcode50.Pow(x, n)剑指 Offer 16. 数值的整数次方--递归快速幂
  4. ORA-01841: (full) year must be between -4713 and +9999, and not be 0 及自定义my_to_date函数
  5. kindeditor获取html
  6. 简述Kali Linux
  7. 25.MT6739插双卡出现modem 异常
  8. python指定一列为KEY 合并多列单元格 并设置单元格行高
  9. 武术进学校 传递正能量
  10. 《C++ primer(第5版)》读书笔记(持续更新)