Skip to content

Commit 097208d

Browse files
committed
Use more idiomatic route configuration
See gh-25110
1 parent 5187695 commit 097208d

File tree

2 files changed

+10
-12
lines changed

2 files changed

+10
-12
lines changed

spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/features/developingwebapplications/springmvc/MyRoutingConfiguration.java

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,6 @@
2323
import org.springframework.web.servlet.function.RouterFunction;
2424
import org.springframework.web.servlet.function.ServerResponse;
2525

26-
import static org.springframework.web.servlet.function.RequestPredicates.DELETE;
27-
import static org.springframework.web.servlet.function.RequestPredicates.GET;
2826
import static org.springframework.web.servlet.function.RequestPredicates.accept;
2927
import static org.springframework.web.servlet.function.RouterFunctions.route;
3028

@@ -36,10 +34,11 @@ public class MyRoutingConfiguration {
3634
@Bean
3735
public RouterFunction<ServerResponse> routerFunction(MyUserHandler userHandler) {
3836
// @formatter:off
39-
return route(
40-
GET("/{user}").and(ACCEPT_JSON), userHandler::getUser).andRoute(
41-
GET("/{user}/customers").and(ACCEPT_JSON), userHandler::getUserCustomers).andRoute(
42-
DELETE("/{user}").and(ACCEPT_JSON), userHandler::deleteUser);
37+
return route()
38+
.GET("/{user}", ACCEPT_JSON, userHandler::getUser)
39+
.GET("/{user}/customers", ACCEPT_JSON, userHandler::getUserCustomers)
40+
.DELETE("/{user}", ACCEPT_JSON, userHandler::deleteUser)
41+
.build();
4342
// @formatter:on
4443
}
4544

spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/features/developingwebapplications/springwebflux/MyRoutingConfiguration.java

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,6 @@
2323
import org.springframework.web.reactive.function.server.RouterFunction;
2424
import org.springframework.web.reactive.function.server.ServerResponse;
2525

26-
import static org.springframework.web.reactive.function.server.RequestPredicates.DELETE;
27-
import static org.springframework.web.reactive.function.server.RequestPredicates.GET;
2826
import static org.springframework.web.reactive.function.server.RequestPredicates.accept;
2927
import static org.springframework.web.reactive.function.server.RouterFunctions.route;
3028

@@ -36,10 +34,11 @@ public class MyRoutingConfiguration {
3634
@Bean
3735
public RouterFunction<ServerResponse> monoRouterFunction(MyUserHandler userHandler) {
3836
// @formatter:off
39-
return route(
40-
GET("/{user}").and(ACCEPT_JSON), userHandler::getUser).andRoute(
41-
GET("/{user}/customers").and(ACCEPT_JSON), userHandler::getUserCustomers).andRoute(
42-
DELETE("/{user}").and(ACCEPT_JSON), userHandler::deleteUser);
37+
return route()
38+
.GET("/{user}", ACCEPT_JSON, userHandler::getUser)
39+
.GET("/{user}/customers", ACCEPT_JSON, userHandler::getUserCustomers)
40+
.DELETE("/{user}", ACCEPT_JSON, userHandler::deleteUser)
41+
.build();
4342
// @formatter:on
4443
}
4544

0 commit comments

Comments
 (0)