This commit is contained in:
Sebastien Deleuze 2016-09-20 14:28:12 +02:00
parent 857e77eec2
commit 1d46b8d7e1
4 changed files with 13 additions and 16 deletions

View File

@ -32,7 +32,8 @@ import org.springframework.http.server.reactive.ServerHttpResponse;
/**
* {@link HttpMessageReader} wrapper that implements {@link ServerHttpMessageReader} in order
* to allow providing hints.
* to allow providing hints to the nested {@code reader} or setting the response status for
* example, by implementing {@link #beforeRead(ResolvableType, ResolvableType, ServerHttpRequest, ServerHttpResponse)}.
*
* @author Sebastien Deleuze
* @since 5.0
@ -92,14 +93,13 @@ public abstract class AbstractServerHttpMessageReader<T> implements ServerHttpMe
/**
* Invoked before reading the request by
* {@link #read(ResolvableType, ResolvableType, ServerHttpRequest, ServerHttpResponse, Map)}
* {@link #read(ResolvableType, ResolvableType, ServerHttpRequest, ServerHttpResponse, Map)}.
*
* @param streamType the original type used for the method return value. For annotation
* based controllers, the {@link MethodParameter} is available via {@link ResolvableType#getSource()}.
* Can be {@code null}.
* @param elementType the stream element type to process
* @param request the current HTTP request, can be {@code null}
* @param response the current HTTP response, can be {@code null}
* @param request the current HTTP request
* @param response the current HTTP response
* @return Additional information about how to write the body
*/
protected abstract Map<String, Object> beforeRead(ResolvableType streamType,

View File

@ -32,9 +32,8 @@ import org.springframework.http.server.reactive.ServerHttpResponse;
/**
* {@link HttpMessageWriter} wrapper that implements {@link ServerHttpMessageWriter} in order
* to allow providing hints to the nested {@code writer} or setting the response status, for
* example, by implementing {@link #beforeWrite(ResolvableType, ResolvableType, MediaType, ServerHttpRequest, ServerHttpResponse)}
*
* to allow providing hints to the nested {@code writer} or setting the response status for
* example, by implementing {@link #beforeWrite(ResolvableType, ResolvableType, MediaType, ServerHttpRequest, ServerHttpResponse)}.
*
* @author Sebastien Deleuze
* @since 5.0
@ -71,7 +70,8 @@ public abstract class AbstractServerHttpMessageWriter<T> implements ServerHttpMe
Map<String, Object> mergedHints = new HashMap<>(hints);
mergedHints.putAll(beforeWrite(streamType, elementType, mediaType, request, response));
return (this.writer instanceof ServerHttpMessageWriter ?
((ServerHttpMessageWriter<T>)this.writer).write(inputStream, streamType, elementType, mediaType, request, response, mergedHints) :
((ServerHttpMessageWriter<T>)this.writer).write(inputStream, streamType,
elementType, mediaType, request, response, mergedHints) :
this.writer.write(inputStream, elementType, mediaType, response, mergedHints));
}
@ -81,12 +81,11 @@ public abstract class AbstractServerHttpMessageWriter<T> implements ServerHttpMe
*
* @param streamType the original type used for the method return value. For annotation
* based controllers, the {@link MethodParameter} is available via {@link ResolvableType#getSource()}.
* Can be {@code null}.
* @param elementType the stream element type to process
* @param mediaType the content type to use when writing. May be {@code null} to
* indicate that the default content type of the converter must be used.
* @param request the current HTTP request, can be {@code null}
* @param response the current HTTP response, can be {@code null}
* @param request the current HTTP request
* @param response the current HTTP response
* @return Additional information about how to write the body
*/
protected abstract Map<String, Object> beforeWrite(ResolvableType streamType, ResolvableType elementType,

View File

@ -21,8 +21,6 @@ import java.util.HashMap;
import java.util.Map;
import com.fasterxml.jackson.annotation.JsonView;
import org.reactivestreams.Publisher;
import reactor.core.publisher.Mono;
import org.springframework.core.MethodParameter;
import org.springframework.core.ResolvableType;

View File

@ -46,8 +46,8 @@ public interface ServerHttpMessageWriter<T> extends HttpMessageWriter<T> {
* @param elementType the stream element type to process
* @param mediaType the content type to use when writing. May be {@code null} to
* indicate that the default content type of the converter must be used.
* @param request the current HTTP request, can be {@code null}
* @param response the current HTTP response, can be {@code null}
* @param request the current HTTP request
* @param response the current HTTP response
* @return a {@link Mono} that indicates completion or error
*/
Mono<Void> write(Publisher<? extends T> inputStream, ResolvableType streamType,