过滤器 RequestSize · SpringCloud微服务实战 · 看云
14. 过滤器 RequestSize
导航
当请求大小高于允许的限制大小时,RequestSize GatewayFilter工厂将会阻止转发到下游服务。过滤器将RequestSize 参数作为请求的允许大小限制(以字节为单位)
本节代码地址
14.1 应用配置
我们在网关的请求中对上传请求做设置,限制大小为5M,当超过请求大小,就会报错
server:
port: 8699
spring:
application:
name: fw-gateways-gateway
profiles:
active: setrequestheader_route
eureka:
client:
service-url:
defaultZone: http://localhost:8761/eureka/
---
spring:
cloud:
gateway:
routes:
- id: request_size_route
uri: lb://fw-cloud-upload
predicates:
- After=2020-01-08T18:30:11.965+08:00[Asia/Shanghai]
filters:
- name: RequestSize
args:
maxSize: 5000000
profiles: request_size_route
14.2 应用启动
需要将上传服务启动起来,浏览器输入localhost:8699/upload

