/** * Server-side only alternative to * {@link #read(ResolvableType, ReactiveHttpInputMessage, Map)} * with additional context available. * @param actualType the actual type of the target method parameter; * for annotated controllers, the {@link MethodParameter} can be accessed * via {@link ResolvableType#getSource()}. * @param elementType the type of Objects in the output stream * @param request the current request * @param response the current response * @param hints additional information about how to read the body * @return the decoded stream of elements */ default Flux<T> read(ResolvableType actualType, ResolvableType elementType, ServerHttpRequest request, ServerHttpResponse response, Map<String, Object> hints) { return read(elementType, request, hints); }
logger.debug(exchange.getLogPrefix() + "0..N [" + elementType + "]"); Flux<?> flux = reader.read(actualType, elementType, request, response, readHints); flux = flux.onErrorResume(ex -> Flux.error(handleReadError(bodyParam, ex))); if (isBodyRequired) {
Flux<?> flux = httpMessageReader.read(bodyType, elementType, request, response, readHints); return Mono.just(adapter.fromPublisher(flux));
/** * Server-side only alternative to * {@link #read(ResolvableType, ReactiveHttpInputMessage, Map)} * with additional context available. * @param actualType the actual type of the target method parameter; * for annotated controllers, the {@link MethodParameter} can be accessed * via {@link ResolvableType#getSource()}. * @param elementType the type of Objects in the output stream * @param request the current request * @param response the current response * @param hints additional information about how to read the body * @return the decoded stream of elements */ default Flux<T> read(ResolvableType actualType, ResolvableType elementType, ServerHttpRequest request, ServerHttpResponse response, Map<String, Object> hints) { return read(elementType, request, hints); }
exchange.getLogPrefix() + "0..N [" + elementType + "]"); Flux<?> flux = reader.read(actualType, elementType, request, response, readHints); flux = flux.onErrorResume(
private static <T> Flux<T> readToFlux(ReactiveHttpInputMessage message, BodyExtractor.Context context, ResolvableType type, HttpMessageReader<T> reader) { return context.serverResponse() .map(response -> reader.read(type, type, (ServerHttpRequest) message, response, context.hints())) .orElseGet(() -> reader.read(type, message, context.hints())); }
exchange.getLogPrefix() + "0..N [" + elementType + "]"); Flux<?> flux = reader.read(actualType, elementType, request, response, readHints); flux = flux.onErrorResume(
@Override public Mono<MultiValueMap<String, Part>> readMono(ResolvableType elementType, ReactiveHttpInputMessage inputMessage, Map<String, Object> hints) { Map<String, Object> allHints = Hints.merge(hints, Hints.SUPPRESS_LOGGING_HINT, true); return this.partReader.read(elementType, inputMessage, allHints) .collectMultimap(Part::name) .doOnNext(map -> { LogFormatUtils.traceDebug(logger, traceOn -> Hints.getLogPrefix(hints) + "Parsed " + (isEnableLoggingRequestDetails() ? LogFormatUtils.formatValue(map, !traceOn) : "parts " + map.keySet() + " (content masked)")); }) .map(this::toMultiValueMap); }
flux = reader.read(elementType, request, readHints);
@Override public Mono<MultiValueMap<String, Part>> readMono(ResolvableType elementType, ReactiveHttpInputMessage inputMessage, Map<String, Object> hints) { Map<String, Object> allHints = Hints.merge(hints, Hints.SUPPRESS_LOGGING_HINT, true); return this.partReader.read(elementType, inputMessage, allHints) .collectMultimap(Part::name) .doOnNext(map -> { LogFormatUtils.traceDebug(logger, traceOn -> Hints.getLogPrefix(hints) + "Parsed " + (isEnableLoggingRequestDetails() ? LogFormatUtils.formatValue(map, !traceOn) : "parts " + map.keySet() + " (content masked)")); }) .map(this::toMultiValueMap); }
/** * Server-side only alternative to * {@link #read(ResolvableType, ReactiveHttpInputMessage, Map)} * with additional context available. * @param actualType the actual type of the target method parameter; * for annotated controllers, the {@link MethodParameter} can be accessed * via {@link ResolvableType#getSource()}. * @param elementType the type of Objects in the output stream * @param request the current request * @param response the current response * @param hints additional information about how to read the body * @return the decoded stream of elements */ default Flux<T> read(ResolvableType actualType, ResolvableType elementType, ServerHttpRequest request, ServerHttpResponse response, Map<String, Object> hints) { return read(elementType, request, hints); }
/** * Server-side only alternative to * {@link #read(ResolvableType, ReactiveHttpInputMessage, Map)} * with additional context available. * @param actualType the actual type of the target method parameter; * for annotated controllers, the {@link MethodParameter} can be accessed * via {@link ResolvableType#getSource()}. * @param elementType the type of Objects in the output stream * @param request the current request * @param response the current response * @param hints additional information about how to read the body * @return the decoded stream of elements */ default Flux<T> read(ResolvableType actualType, ResolvableType elementType, ServerHttpRequest request, ServerHttpResponse response, Map<String, Object> hints) { return read(elementType, request, hints); }
@Override public Mono<MultiValueMap<String, Part>> readMono(ResolvableType elementType, ReactiveHttpInputMessage inputMessage, Map<String, Object> hints) { return this.partReader.read(elementType, inputMessage, hints) .collectMultimap(Part::name).map(this::toMultiValueMap); }
/** * Return a {@code BodyExtractor} that reads into a Reactor {@link Flux}. * @param elementType the type of element in the {@code Flux} * @param <T> the element type * @return a {@code BodyExtractor} that reads a mono */ public static <T> BodyExtractor<Flux<T>, ReactiveHttpInputMessage> toFlux(ResolvableType elementType) { Assert.notNull(elementType, "'elementType' must not be null"); return (inputMessage, context) -> readWithMessageReaders(inputMessage, context, elementType, reader -> reader.read(elementType, inputMessage, context.hints()), Flux::error); }
@Override public Mono<MultiValueMap<String, Part>> readMono(ResolvableType elementType, ReactiveHttpInputMessage inputMessage, Map<String, Object> hints) { Map<String, Object> allHints = Hints.merge(hints, Hints.SUPPRESS_LOGGING_HINT, true); return this.partReader.read(elementType, inputMessage, allHints) .collectMultimap(Part::name) .doOnNext(map -> { LogFormatUtils.traceDebug(logger, traceOn -> Hints.getLogPrefix(hints) + "Parsed " + (isEnableLoggingRequestDetails() ? LogFormatUtils.formatValue(map, !traceOn) : "parts " + map.keySet() + " (content masked)")); }) .map(this::toMultiValueMap); }