Expose BodyInserter in EntityResponse

This commit is contained in:
Arjen Poutsma 2017-02-13 15:09:36 +01:00
parent 44ec6e0037
commit dff9b3b85c
2 changed files with 12 additions and 0 deletions

View File

@ -196,6 +196,11 @@ class DefaultEntityResponseBuilder<T> implements EntityResponse.Builder<T> {
return this.entity;
}
@Override
public BodyInserter<T, ? super ServerHttpResponse> inserter() {
return this.inserter;
}
@Override
public Mono<Void> writeTo(ServerWebExchange exchange, HandlerStrategies strategies) {
ServerHttpResponse response = exchange.getResponse();

View File

@ -30,6 +30,8 @@ import org.springframework.http.HttpMethod;
import org.springframework.http.HttpStatus;
import org.springframework.http.MediaType;
import org.springframework.http.codec.json.AbstractJackson2Codec;
import org.springframework.http.server.reactive.ServerHttpResponse;
import org.springframework.web.reactive.function.BodyInserter;
import org.springframework.web.reactive.function.BodyInserters;
/**
@ -45,6 +47,11 @@ public interface EntityResponse<T> extends ServerResponse {
*/
T entity();
/**
* Return the {@code BodyInserter} that writes the entity to the output stream.
*/
BodyInserter<T, ? super ServerHttpResponse> inserter();
// Static builder methods
/**