Fix pathExtension null-safety in Kotlin DSLs

Closes gh-32254
This commit is contained in:
Sébastien Deleuze
2024-02-13 14:24:19 +01:00
parent 8c3fc8c549
commit 2fe3321813
6 changed files with 40 additions and 6 deletions

View File

@@ -112,6 +112,15 @@ class CoRouterFunctionDslTests {
.verifyComplete()
}
@Test
fun pathExtension() {
val mockRequest = get("https://example.com/test.properties").build()
val request = DefaultServerRequest(MockServerWebExchange.from(mockRequest), emptyList())
StepVerifier.create(sampleRouter().route(request))
.expectNextCount(1)
.verifyComplete()
}
@Test
fun resource() {
val mockRequest = get("https://example.com/response2.txt").build()
@@ -324,6 +333,9 @@ class CoRouterFunctionDslTests {
null
}
}
GET("/**", pathExtension { it == "properties" }) {
ok().bodyValueAndAwait("foo=bar")
}
path("/baz", ::handle)
GET("/rendering") { RenderingResponse.create("index").buildAndAwait() }
add(otherRouter)

View File

@@ -110,6 +110,15 @@ class RouterFunctionDslTests {
.verifyComplete()
}
@Test
fun pathExtension() {
val mockRequest = get("https://example.com/test.properties").build()
val request = DefaultServerRequest(MockServerWebExchange.from(mockRequest), emptyList())
StepVerifier.create(sampleRouter().route(request))
.expectNextCount(1)
.verifyComplete()
}
@Test
fun resource() {
val mockRequest = get("https://example.com/response2.txt").build()
@@ -256,6 +265,9 @@ class RouterFunctionDslTests {
Mono.empty()
}
}
GET(pathExtension { it == "properties" }) {
ok().bodyValue("foo=bar")
}
path("/baz", ::handle)
GET("/rendering") { RenderingResponse.create("index").build() }
add(otherRouter)