From 170057005e4960035e2b8fc2d0f11ac63295473b Mon Sep 17 00:00:00 2001 From: Sebastien Deleuze Date: Wed, 15 Mar 2017 17:21:04 +0100 Subject: [PATCH] Use .nest() instead of .route() in Kotlin Web DSL The goal is to have better consistency between Java and Kotlin functional Web API. --- .../web/reactive/function/server/RouterFunctionExtensions.kt | 4 ++-- .../reactive/function/server/RouterFunctionExtensionsTests.kt | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/spring-webflux/src/main/kotlin/org/springframework/web/reactive/function/server/RouterFunctionExtensions.kt b/spring-webflux/src/main/kotlin/org/springframework/web/reactive/function/server/RouterFunctionExtensions.kt index 18c05f6e07..9288040607 100644 --- a/spring-webflux/src/main/kotlin/org/springframework/web/reactive/function/server/RouterFunctionExtensions.kt +++ b/spring-webflux/src/main/kotlin/org/springframework/web/reactive/function/server/RouterFunctionExtensions.kt @@ -80,11 +80,11 @@ class RouterDsl { operator fun RequestPredicate.not(): RequestPredicate = this.negate() - fun RequestPredicate.route(r: Routes) { + fun RequestPredicate.nest(r: Routes) { routes += RouterFunctions.nest(this, RouterDsl().apply(r).router()) } - fun String.route(r: Routes) { + fun String.nest(r: Routes) { routes += RouterFunctions.nest(pathPrefix(this), RouterDsl().apply(r).router()) } diff --git a/spring-webflux/src/test/kotlin/org/springframework/web/reactive/function/server/RouterFunctionExtensionsTests.kt b/spring-webflux/src/test/kotlin/org/springframework/web/reactive/function/server/RouterFunctionExtensionsTests.kt index 5663ade678..443ab616d3 100644 --- a/spring-webflux/src/test/kotlin/org/springframework/web/reactive/function/server/RouterFunctionExtensionsTests.kt +++ b/spring-webflux/src/test/kotlin/org/springframework/web/reactive/function/server/RouterFunctionExtensionsTests.kt @@ -107,7 +107,7 @@ class RouterFunctionExtensionsTests { fun sampleRouter() = router { (GET("/foo/") or GET("/foos/")) { req -> handle(req) } - "/api".route { + "/api".nest { POST("/foo/", ::handleFromClass) PUT("/foo/", :: handleFromClass) "/foo/" { handleFromClass(it) } @@ -115,7 +115,7 @@ class RouterFunctionExtensionsTests { accept(APPLICATION_ATOM_XML, ::handle) contentType(APPLICATION_OCTET_STREAM, ::handle) method(PATCH, ::handle) - headers({ it.accept().contains(APPLICATION_JSON) }).route { + headers({ it.accept().contains(APPLICATION_JSON) }).nest { GET("/api/foo/", ::handle) } headers({ it.header("bar").isNotEmpty() }, ::handle)