Add Consumer methods to RSocketRequester
Closes gh-23513
This commit is contained in:
@@ -18,6 +18,7 @@ package org.springframework.messaging.rsocket;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.Map;
|
||||
import java.util.function.Consumer;
|
||||
|
||||
import io.rsocket.Payload;
|
||||
import io.rsocket.RSocket;
|
||||
@@ -133,6 +134,12 @@ final class DefaultRSocketRequester implements RSocketRequester {
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public RequestSpec metadata(Consumer<RequestSpec> configurer) {
|
||||
configurer.accept(this);
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ResponseSpec data(Object data) {
|
||||
Assert.notNull(data, "'data' must not be null");
|
||||
|
||||
@@ -135,6 +135,12 @@ final class DefaultRSocketRequesterBuilder implements RSocketRequester.Builder {
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public RSocketRequester.Builder apply(Consumer<RSocketRequester.Builder> configurer) {
|
||||
configurer.accept(this);
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Mono<RSocketRequester> connectTcp(String host, int port) {
|
||||
return connect(TcpClientTransport.create(host, port));
|
||||
|
||||
@@ -197,6 +197,14 @@ public interface RSocketRequester {
|
||||
*/
|
||||
RSocketRequester.Builder rsocketFactory(ClientRSocketFactoryConfigurer configurer);
|
||||
|
||||
/**
|
||||
* Configure this builder through a {@code Consumer}. This enables
|
||||
* libraries such as Spring Security to provide shortcuts for applying
|
||||
* a set of related customizations.
|
||||
* @param configurer the configurer to apply
|
||||
*/
|
||||
RSocketRequester.Builder apply(Consumer<RSocketRequester.Builder> configurer);
|
||||
|
||||
/**
|
||||
* Connect to the server over TCP.
|
||||
* @param host the server host
|
||||
@@ -240,6 +248,15 @@ public interface RSocketRequester {
|
||||
*/
|
||||
RequestSpec metadata(Object metadata, MimeType mimeType);
|
||||
|
||||
/**
|
||||
* Append additional metadata entries through a {@code Consumer}.
|
||||
* This enables libraries such as Spring Security to provide shortcuts
|
||||
* for applying a set of customizations.
|
||||
* @param configurer the configurer to apply
|
||||
* @throws IllegalArgumentException if not using composite metadata.
|
||||
*/
|
||||
RequestSpec metadata(Consumer<RequestSpec> configurer);
|
||||
|
||||
/**
|
||||
* Provide payload data for the request. This can be one of:
|
||||
* <ul>
|
||||
|
||||
Reference in New Issue
Block a user