Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Meiracle
spring-framework
提交
a1d134b0
S
spring-framework
项目概览
Meiracle
/
spring-framework
与 Fork 源项目一致
从无法访问的项目Fork
通知
2
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
S
spring-framework
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
a1d134b0
编写于
11月 04, 2020
作者:
M
mplain
提交者:
Sébastien Deleuze
12月 07, 2020
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Add missing Kotlin extensions for WebClient.ResponseSpec
Closes gh-26030
上级
3c85c263
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
49 addition
and
0 deletion
+49
-0
spring-webflux/src/main/kotlin/org/springframework/web/reactive/function/client/WebClientExtensions.kt
...ework/web/reactive/function/client/WebClientExtensions.kt
+31
-0
spring-webflux/src/test/kotlin/org/springframework/web/reactive/function/client/WebClientExtensionsTests.kt
.../web/reactive/function/client/WebClientExtensionsTests.kt
+18
-0
未找到文件。
spring-webflux/src/main/kotlin/org/springframework/web/reactive/function/client/WebClientExtensions.kt
浏览文件 @
a1d134b0
...
...
@@ -25,6 +25,7 @@ import kotlinx.coroutines.reactor.asFlux
import
kotlinx.coroutines.reactor.mono
import
org.reactivestreams.Publisher
import
org.springframework.core.ParameterizedTypeReference
import
org.springframework.http.ResponseEntity
import
org.springframework.web.reactive.function.client.WebClient.RequestBodySpec
import
org.springframework.web.reactive.function.client.WebClient.RequestHeadersSpec
import
reactor.core.publisher.Flux
...
...
@@ -138,3 +139,33 @@ inline fun <reified T : Any> WebClient.ResponseSpec.bodyToFlow(): Flow<T> =
*/
suspend
inline
fun
<
reified
T
:
Any
>
WebClient
.
ResponseSpec
.
awaitBody
()
:
T
=
bodyToMono
<
T
>().
awaitSingle
()
/**
* Extension for [WebClient.ResponseSpec.toEntity] providing a `toEntity<Foo>()` variant
* leveraging Kotlin reified type parameters. This extension is not subject to type
* erasure and retains actual generic type arguments.
*
* @since 5.3.2
*/
inline
fun
<
reified
T
:
Any
>
WebClient
.
ResponseSpec
.
toEntity
():
Mono
<
ResponseEntity
<
T
>>
=
toEntity
(
object
:
ParameterizedTypeReference
<
T
>()
{})
/**
* Extension for [WebClient.ResponseSpec.toEntityList] providing a `toEntityList<Foo>()` variant
* leveraging Kotlin reified type parameters. This extension is not subject to type
* erasure and retains actual generic type arguments.
*
* @since 5.3.2
*/
inline
fun
<
reified
T
:
Any
>
WebClient
.
ResponseSpec
.
toEntityList
():
Mono
<
ResponseEntity
<
List
<
T
>>>
=
toEntityList
(
object
:
ParameterizedTypeReference
<
T
>()
{})
/**
* Extension for [WebClient.ResponseSpec.toEntityFlux] providing a `toEntityFlux<Foo>()` variant
* leveraging Kotlin reified type parameters. This extension is not subject to type
* erasure and retains actual generic type arguments.
*
* @since 5.3.2
*/
inline
fun
<
reified
T
:
Any
>
WebClient
.
ResponseSpec
.
toEntityFlux
():
Mono
<
ResponseEntity
<
Flux
<
T
>>>
=
toEntityFlux
(
object
:
ParameterizedTypeReference
<
T
>()
{})
spring-webflux/src/test/kotlin/org/springframework/web/reactive/function/client/WebClientExtensionsTests.kt
浏览文件 @
a1d134b0
...
...
@@ -125,5 +125,23 @@ class WebClientExtensionsTests {
}
}
@Test
fun
`ResponseSpec
#
toEntity
with
reified
type
parameters`
()
{
responseSpec
.
toEntity
<
List
<
Foo
>>()
verify
{
responseSpec
.
toEntity
(
object
:
ParameterizedTypeReference
<
List
<
Foo
>>()
{})
}
}
@Test
fun
`ResponseSpec
#
toEntityList
with
reified
type
parameters`
()
{
responseSpec
.
toEntityList
<
List
<
Foo
>>()
verify
{
responseSpec
.
toEntityList
(
object
:
ParameterizedTypeReference
<
List
<
Foo
>>()
{})
}
}
@Test
fun
`ResponseSpec
#
toEntityFlux
with
reified
type
parameters`
()
{
responseSpec
.
toEntityFlux
<
List
<
Foo
>>()
verify
{
responseSpec
.
toEntityFlux
(
object
:
ParameterizedTypeReference
<
List
<
Foo
>>()
{})
}
}
class
Foo
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录