跳到正文
cccskills
免费在 GitHub 公开

spring-cloud-gateway

Use when building Spring Cloud Gateway 5 on Spring Boot 4, including WebFlux or Web MVC routes, edge authentication, trusted headers, rate limits, timeouts, and resilience. Do not use for ordinary outbound HTTP clients or domain orchestration.

中文简介正在准备中。当前显示原文说明。

查看安装方法

包含的文件(5)

  • SKILL.md4.2 KB
  • agents/openai.yaml204 B
  • examples/bad-routes.yml281 B
  • examples/good-routes.yml374 B
  • examples/good-webmvc-routes.yml284 B

SKILL.md(原文)

安装前可以查看交给 AI 代理的指令内容。

Spring Cloud Gateway 5

Keep the gateway an edge adapter. Do not move domain workflows into filters.

Compatibility and dependencies

  • Use the latest Spring Cloud 2025.1.x release train for Spring Boot 4.
  • Boot 4.1 support starts with Spring Cloud 2025.1.2.
  • Import spring-cloud-dependencies as a BOM and omit versions from individual Cloud dependencies.
  • Choose exactly one gateway runtime.
<!-- Reactive Netty gateway -->
<dependency>
    <groupId>org.springframework.cloud</groupId>
    <artifactId>spring-cloud-starter-gateway-server-webflux</artifactId>
</dependency>

<!-- OR servlet gateway: spring-cloud-starter-gateway-server-webmvc -->

Do not use the old spring-cloud-starter-gateway coordinate or force a Boot 3 release train onto Boot 4. WebFlux requires Reactor Netty and cannot run as a traditional servlet WAR; Web MVC uses a servlet runtime and WebMvc.fn.

Gateway 5 configuration namespaces

Gateway 5 separates server implementations in configuration:

  • WebFlux: spring.cloud.gateway.server.webflux.*
  • Web MVC: spring.cloud.gateway.server.webmvc.*
spring:
  cloud:
    gateway:
      server:
        webflux:
          httpclient:
            connect-timeout: 2000
            response-timeout: 5s
          routes:
            - id: orders-api
              uri: http://orders.internal
              predicates:
                - Path=/api/orders/**
              filters:
                - RemoveRequestHeader=X-User-Id

The Boot 3-era spring.cloud.gateway.routes and spring.cloud.gateway.httpclient paths do not bind to Gateway 5's WebFlux server properties.

Route and security rules

  • Use stable route IDs and explicit predicates.
  • Remove client-provided forwarding, identity, and internal headers before creating trusted values.
  • Keep path and host rewriting visible and covered by tests.
  • Authenticate at the edge and authorize again in downstream services.
  • Relay tokens only to services with the intended audience.
  • Rate-limit by authenticated identity or a verified API key, not an untrusted address header.
  • Set global connection and response timeouts with narrow route overrides.
  • Retry only proven idempotent operations and only before response commitment.
  • Keep fallbacks bounded and expose sustained upstream failure.

Testing and operations

  • Test predicates, filters, trusted headers, CORS, timeouts, body limits, and status mapping.
  • Use a controlled upstream server rather than mocking gateway internals.
  • Record route ID, outcome, latency, and upstream failure with bounded metric tags.
  • Test each selected runtime with its matching Spring Cloud Gateway test support.

Examples

  • examples/good-routes.yml shows Gateway 5 WebFlux configuration.
  • examples/good-webmvc-routes.yml shows Gateway 5 Web MVC configuration.
  • examples/bad-routes.yml preserves the stale configuration as a warning.

Official sources

Gotchas

  • Agent uses spring.cloud.gateway.routes on Gateway 5 - use the server-specific namespace.
  • Agent uses spring-cloud-starter-gateway on Boot 4 - select the WebFlux or Web MVC server starter.
  • Agent selects a Cloud train without checking the exact Boot line - use the compatibility matrix.
  • Agent trusts a public identity header - derive identity after authentication.
  • Agent retries POST requests automatically - retry only proven idempotent operations.
  • Agent puts business orchestration in filters - keep domain logic downstream.
  • Agent omits response timeouts - stalled upstreams can exhaust resources.

评价

还没有评价。欢迎分享你的使用感受。

评论

无需登录即可发表。欢迎分享使用感受、提问,或说明在哪些环境下无法运行。

还没有评论。来写第一条吧。

提交后会立即公开。请勿填写邮箱、电话等个人信息。URL 最多 2 个。

0 / 1000 字

此表单受 reCAPTCHA 保护,适用 Google 的隐私权政策和服务条款。

同一仓库的技能

Use when adding Spring AI-specific model observations, token usage, latency, externally configured cost attribution, advisor telemetry, or protected prompt and completion logging. Use production-observability for general service metrics, health, logs, and OTLP setup.

中文简介正在准备中。当前显示原文说明。

rrezartprebreza/spring-boot-skills3212026年10月22日 更新

Use when versioning Spring MVC or WebFlux APIs in Spring Boot 3 / Spring Framework 6. Covers explicit URL, header, and media-type strategies, compatibility rules, and deprecation handling.

中文简介正在准备中。当前显示原文说明。

rrezartprebreza/spring-boot-skills3212026年10月22日 更新

Use when versioning Spring MVC or WebFlux APIs in Spring Boot 4 / Spring Framework 7. Covers built-in mapping versions, request version resolution, defaults, supported versions, and deprecation headers.

中文简介正在准备中。当前显示原文说明。

rrezartprebreza/spring-boot-skills3212026年10月22日 更新

Use when introducing or correcting grouped Spring Boot configuration, typed property binding, validation, profiles or secret injection. Do not rewrite unrelated single-value configuration.

中文简介正在准备中。当前显示原文说明。

rrezartprebreza/spring-boot-skills3212026年10月22日 更新

Use when packaging Spring Boot 4 as an OCI image, JVM container, AOT application, or GraalVM native executable. Covers buildpacks, layers, runtime hints, probes, security, and verification.

中文简介正在准备中。当前显示原文说明。

rrezartprebreza/spring-boot-skills3212026年10月22日 更新

Use when packaging a Spring Boot 3 application as an OCI image or GraalVM native executable. Covers buildpacks, layered images, JVM containers, AOT hints, probes, security, and verification.

中文简介正在准备中。当前显示原文说明。

rrezartprebreza/spring-boot-skills3212026年10月22日 更新

查看 rrezartprebreza 的全部技能

报告此技能的问题