/** * Get decoding hints based on the server request or annotations on the * target controller method parameter. * @param actualType the actual source type to encode, possibly a reactive * wrapper and sourced from {@link org.springframework.core.MethodParameter}, * i.e. providing access to method annotations. * @param elementType the element type within {@code Flux/Mono} that we're * trying to encode. * @param request the current request * @param response the current response * @return a Map with hints, possibly empty */ default Map<String, Object> getEncodeHints(ResolvableType actualType, ResolvableType elementType, @Nullable MediaType mediaType, ServerHttpRequest request, ServerHttpResponse response) { return Hints.none(); }
private Map<String, Object> getEncodeHints(ResolvableType actualType, ResolvableType elementType, @Nullable MediaType mediaType, ServerHttpRequest request, ServerHttpResponse response) { if (this.encoder instanceof HttpMessageEncoder) { HttpMessageEncoder<?> encoder = (HttpMessageEncoder<?>) this.encoder; return encoder.getEncodeHints(actualType, elementType, mediaType, request, response); } return Hints.none(); }
/** * Get additional hints for decoding for example based on the server request * or annotations from controller method parameters. By default, delegate to * the decoder if it is an instance of {@link HttpMessageDecoder}. */ protected Map<String, Object> getReadHints(ResolvableType actualType, ResolvableType elementType, ServerHttpRequest request, ServerHttpResponse response) { if (this.decoder instanceof HttpMessageDecoder) { HttpMessageDecoder<?> decoder = (HttpMessageDecoder<?>) this.decoder; return decoder.getDecodeHints(actualType, elementType, request, response); } return Hints.none(); }
@Override public Map<String, Object> getEncodeHints(@Nullable ResolvableType actualType, ResolvableType elementType, @Nullable MediaType mediaType, ServerHttpRequest request, ServerHttpResponse response) { return (actualType != null ? getHints(actualType) : Hints.none()); }
/** * Get additional hints for encoding for example based on the server request * or annotations from controller method parameters. By default, delegate to * the encoder if it is an instance of {@link HttpMessageEncoder}. */ protected Map<String, Object> getWriteHints(ResolvableType streamType, ResolvableType elementType, @Nullable MediaType mediaType, ServerHttpRequest request, ServerHttpResponse response) { if (this.encoder instanceof HttpMessageEncoder) { HttpMessageEncoder<?> encoder = (HttpMessageEncoder<?>) this.encoder; return encoder.getEncodeHints(streamType, elementType, mediaType, request, response); } return Hints.none(); }
/** * Get decoding hints based on the server request or annotations on the * target controller method parameter. * @param actualType the actual source type to encode, possibly a reactive * wrapper and sourced from {@link org.springframework.core.MethodParameter}, * i.e. providing access to method annotations. * @param elementType the element type within {@code Flux/Mono} that we're * trying to encode. * @param request the current request * @param response the current response * @return a Map with hints, possibly empty */ default Map<String, Object> getEncodeHints(ResolvableType actualType, ResolvableType elementType, @Nullable MediaType mediaType, ServerHttpRequest request, ServerHttpResponse response) { return Hints.none(); }
private Map<String, Object> getEncodeHints(ResolvableType actualType, ResolvableType elementType, @Nullable MediaType mediaType, ServerHttpRequest request, ServerHttpResponse response) { if (this.encoder instanceof HttpMessageEncoder) { HttpMessageEncoder<?> encoder = (HttpMessageEncoder<?>) this.encoder; return encoder.getEncodeHints(actualType, elementType, mediaType, request, response); } return Hints.none(); }
@Override public Map<String, Object> getEncodeHints(@Nullable ResolvableType actualType, ResolvableType elementType, @Nullable MediaType mediaType, ServerHttpRequest request, ServerHttpResponse response) { return (actualType != null ? getHints(actualType) : Hints.none()); }
/** * Get additional hints for encoding for example based on the server request * or annotations from controller method parameters. By default, delegate to * the encoder if it is an instance of {@link HttpMessageEncoder}. */ protected Map<String, Object> getWriteHints(ResolvableType streamType, ResolvableType elementType, @Nullable MediaType mediaType, ServerHttpRequest request, ServerHttpResponse response) { if (this.encoder instanceof HttpMessageEncoder) { HttpMessageEncoder<?> encoder = (HttpMessageEncoder<?>) this.encoder; return encoder.getEncodeHints(streamType, elementType, mediaType, request, response); } return Hints.none(); }
/** * Get additional hints for decoding for example based on the server request * or annotations from controller method parameters. By default, delegate to * the decoder if it is an instance of {@link HttpMessageDecoder}. */ protected Map<String, Object> getReadHints(ResolvableType actualType, ResolvableType elementType, ServerHttpRequest request, ServerHttpResponse response) { if (this.decoder instanceof HttpMessageDecoder) { HttpMessageDecoder<?> decoder = (HttpMessageDecoder<?>) this.decoder; return decoder.getDecodeHints(actualType, elementType, request, response); } return Hints.none(); }
protected Map<String, Object> getHints(ResolvableType resolvableType) { MethodParameter param = getParameter(resolvableType); if (param != null) { JsonView annotation = getAnnotation(param, JsonView.class); if (annotation != null) { Class<?>[] classes = annotation.value(); Assert.isTrue(classes.length == 1, JSON_VIEW_HINT_ERROR + param); return Hints.from(JSON_VIEW_HINT, classes[0]); } } return Hints.none(); }
@SuppressWarnings("unchecked") private static Mono<MultiValueMap<String, String>> initFormData(ServerHttpRequest request, List<HttpMessageReader<?>> readers) { try { MediaType contentType = request.getHeaders().getContentType(); if (MediaType.APPLICATION_FORM_URLENCODED.isCompatibleWith(contentType)) { return ((HttpMessageReader<MultiValueMap<String, String>>) readers.stream() .filter(reader -> reader.canRead(FORM_DATA_TYPE, MediaType.APPLICATION_FORM_URLENCODED)) .findFirst() .orElseThrow(() -> new IllegalStateException("No form data HttpMessageReader."))) .readMono(FORM_DATA_TYPE, request, Hints.none()) .switchIfEmpty(EMPTY_FORM_DATA) .cache(); } } catch (InvalidMediaTypeException ex) { // Ignore } return EMPTY_FORM_DATA; }
@SuppressWarnings("unchecked") private static Mono<MultiValueMap<String, Part>> initMultipartData(ServerHttpRequest request, List<HttpMessageReader<?>> readers) { try { MediaType contentType = request.getHeaders().getContentType(); if (MediaType.MULTIPART_FORM_DATA.isCompatibleWith(contentType)) { return ((HttpMessageReader<MultiValueMap<String, Part>>) readers.stream() .filter(reader -> reader.canRead(MULTIPART_DATA_TYPE, MediaType.MULTIPART_FORM_DATA)) .findFirst() .orElseThrow(() -> new IllegalStateException("No multipart HttpMessageReader."))) .readMono(MULTIPART_DATA_TYPE, request, Hints.none()) .switchIfEmpty(EMPTY_MULTIPART_DATA) .cache(); } } catch (InvalidMediaTypeException ex) { // Ignore } return EMPTY_MULTIPART_DATA; } @Override
protected Map<String, Object> getHints(ResolvableType resolvableType) { MethodParameter param = getParameter(resolvableType); if (param != null) { JsonView annotation = getAnnotation(param, JsonView.class); if (annotation != null) { Class<?>[] classes = annotation.value(); Assert.isTrue(classes.length == 1, JSON_VIEW_HINT_ERROR + param); return Hints.from(JSON_VIEW_HINT, classes[0]); } } return Hints.none(); }
/** * Get decoding hints based on the server request or annotations on the * target controller method parameter. * @param actualType the actual source type to encode, possibly a reactive * wrapper and sourced from {@link org.springframework.core.MethodParameter}, * i.e. providing access to method annotations. * @param elementType the element type within {@code Flux/Mono} that we're * trying to encode. * @param request the current request * @param response the current response * @return a Map with hints, possibly empty */ default Map<String, Object> getEncodeHints(ResolvableType actualType, ResolvableType elementType, @Nullable MediaType mediaType, ServerHttpRequest request, ServerHttpResponse response) { return Hints.none(); }
@Override public Map<String, Object> getEncodeHints(@Nullable ResolvableType actualType, ResolvableType elementType, @Nullable MediaType mediaType, ServerHttpRequest request, ServerHttpResponse response) { return (actualType != null ? getHints(actualType) : Hints.none()); }
/** * Get additional hints for decoding for example based on the server request * or annotations from controller method parameters. By default, delegate to * the decoder if it is an instance of {@link HttpMessageDecoder}. */ protected Map<String, Object> getReadHints(ResolvableType actualType, ResolvableType elementType, ServerHttpRequest request, ServerHttpResponse response) { if (this.decoder instanceof HttpMessageDecoder) { HttpMessageDecoder<?> decoder = (HttpMessageDecoder<?>) this.decoder; return decoder.getDecodeHints(actualType, elementType, request, response); } return Hints.none(); }
/** * Get additional hints for encoding for example based on the server request * or annotations from controller method parameters. By default, delegate to * the encoder if it is an instance of {@link HttpMessageEncoder}. */ protected Map<String, Object> getWriteHints(ResolvableType streamType, ResolvableType elementType, @Nullable MediaType mediaType, ServerHttpRequest request, ServerHttpResponse response) { if (this.encoder instanceof HttpMessageEncoder) { HttpMessageEncoder<?> encoder = (HttpMessageEncoder<?>) this.encoder; return encoder.getEncodeHints(streamType, elementType, mediaType, request, response); } return Hints.none(); }
private Map<String, Object> getEncodeHints(ResolvableType actualType, ResolvableType elementType, @Nullable MediaType mediaType, ServerHttpRequest request, ServerHttpResponse response) { if (this.encoder instanceof HttpMessageEncoder) { HttpMessageEncoder<?> encoder = (HttpMessageEncoder<?>) this.encoder; return encoder.getEncodeHints(actualType, elementType, mediaType, request, response); } return Hints.none(); }
protected Map<String, Object> getHints(ResolvableType resolvableType) { MethodParameter param = getParameter(resolvableType); if (param != null) { JsonView annotation = getAnnotation(param, JsonView.class); if (annotation != null) { Class<?>[] classes = annotation.value(); Assert.isTrue(classes.length == 1, JSON_VIEW_HINT_ERROR + param); return Hints.from(JSON_VIEW_HINT, classes[0]); } } return Hints.none(); }