From 35c530e59bbe441eabadb032d20c0f9f19be3fa6 Mon Sep 17 00:00:00 2001 From: tungj Date: Sat, 9 Mar 2024 01:33:18 +0800 Subject: [PATCH] Fix documentation sample imports and missing .build() call (#3223) * Fix javadoc sample imports and missing .build() call * Correct static import and missing .build() in second example --- .../java-routes-api.adoc | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/docs/modules/ROOT/pages/spring-cloud-gateway-server-mvc/java-routes-api.adoc b/docs/modules/ROOT/pages/spring-cloud-gateway-server-mvc/java-routes-api.adoc index 27680cfa..d48fa7b4 100644 --- a/docs/modules/ROOT/pages/spring-cloud-gateway-server-mvc/java-routes-api.adoc +++ b/docs/modules/ROOT/pages/spring-cloud-gateway-server-mvc/java-routes-api.adoc @@ -8,13 +8,13 @@ A https://docs.spring.io/spring-framework/docs/current/javadoc-api/org/springfra .GatewaySampleApplication.java [source,java] ---- -import org.springframework.web.servlet.function.RouterFunctions.route; +import static org.springframework.web.servlet.function.RouterFunctions.route; import static org.springframework.cloud.gateway.server.mvc.handler.HandlerFunctions.http; class SimpleGateway { @Bean public RouterFunction getRoute() { - return route().GET("/get", http("https://httpbin.org")); + return route().GET("/get", http("https://httpbin.org")).build(); } } ---- @@ -29,13 +29,13 @@ Some advanced filters require some metadata to be added to request attributes. T .GatewaySampleApplication.java [source,java] ---- -import org.springframework.cloud.gateway.server.mvc.handler.GatewayRouterFunctions; +import static org.springframework.cloud.gateway.server.mvc.handler.GatewayRouterFunctions; import static org.springframework.cloud.gateway.server.mvc.handler.HandlerFunctions.http; class SimpleGateway { @Bean public RouterFunction getRoute() { - return route("simple_route").GET("/get", http("https://httpbin.org")); + return route("simple_route").GET("/get", http("https://httpbin.org")).build(); } } ---- @@ -43,4 +43,4 @@ class SimpleGateway { [[gateway-handlerfunctions]] == Gateway MVC Handler Functions -Various `RouterFunctions.Builder` methods require a `HandlerFunction`. To create a route that is proxied by the MVC Gateway, `HandlerFunction` implementations are supplied in `org.springframework.cloud.gateway.server.mvc.handler.HandlerFunctions`. The most basic is the `http()` `HandlerFunction`. If a `URI` is supplied as a parameter, that is the `URI` used as the downstream target for sending the HTTP requests (as seen in the example above). If no parameter is passed, the function looks for a `URI` in the `org.springframework.cloud.gateway.server.mvc.common.MvcUtils.GATEWAY_REQUEST_URL_ATTR` request attribute. This allows for dynamic targets such as load balancing to set the `URI`. \ No newline at end of file +Various `RouterFunctions.Builder` methods require a `HandlerFunction`. To create a route that is proxied by the MVC Gateway, `HandlerFunction` implementations are supplied in `org.springframework.cloud.gateway.server.mvc.handler.HandlerFunctions`. The most basic is the `http()` `HandlerFunction`. If a `URI` is supplied as a parameter, that is the `URI` used as the downstream target for sending the HTTP requests (as seen in the example above). If no parameter is passed, the function looks for a `URI` in the `org.springframework.cloud.gateway.server.mvc.common.MvcUtils.GATEWAY_REQUEST_URL_ATTR` request attribute. This allows for dynamic targets such as load balancing to set the `URI`.