You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: spring-webflux/src/main/kotlin/org/springframework/web/reactive/function/server/ServerRequestExtensions.kt
+11-1
Original file line number
Diff line number
Diff line change
@@ -35,7 +35,7 @@ import kotlin.reflect.KClass
35
35
* Extension for [ServerRequest.bodyToMono] providing a `bodyToMono<Foo>()` variant
36
36
* leveraging Kotlin reified type parameters. This extension is not subject to type
37
37
* erasure and retains actual generic type arguments.
38
-
*
38
+
*
39
39
* @author Sebastien Deleuze
40
40
* @since 5.0
41
41
*/
@@ -192,3 +192,13 @@ fun ServerRequest.Headers.contentLengthOrNull(): Long? =
192
192
*/
193
193
fun ServerRequest.Headers.contentTypeOrNull(): MediaType?=
194
194
contentType().orElse(null)
195
+
196
+
/**
197
+
* Nullable variant of [ServerRequest.pathVariable].
198
+
*
199
+
* @author George Papadopoulos
200
+
* @since 6.2
201
+
*/
202
+
fun ServerRequest.pathVariableOrNull(name:String): String? {
Copy file name to clipboardExpand all lines: spring-webflux/src/test/kotlin/org/springframework/web/reactive/function/server/ServerRequestExtensionsTests.kt
+14
Original file line number
Diff line number
Diff line change
@@ -222,5 +222,19 @@ class ServerRequestExtensionsTests {
222
222
verify { headers.contentType() }
223
223
}
224
224
225
+
@Test
226
+
fun`pathVariableOrNull with value`() {
227
+
every { request.pathVariables() } returns hashMapOf("name" to "123")
0 commit comments