Add validation support into WebFlux Inbound (#2977)

* Add validation support into WebFlux Inbound

See https://stackoverflow.com/questions/56729517/spring-integration-webflux-validate-input-json-body

* Introduce a `WebFluxInboundEndpoint.validator` option to validate
a request payload after conversion HTTP request into a `Publisher`
* Expose a `WebFluxInboundEndpointSpec.validator()` option
* Introduce a `IntegrationWebExchangeBindException` to extend a
`WebExchangeBindException` for Spring Integration use-case.
such an exception is used in the `ResponseStatusExceptionHandler`
extensions, like one in Spring Boot for proper response rendering
* Test and document the solution

* * Remove unused imports from IntegrationWebExchangeBindException
This commit is contained in:
Artem Bilan
2019-06-26 11:11:33 -04:00
committed by Gary Russell
parent 97aaf95ccb
commit 59cdc4ddae
7 changed files with 231 additions and 46 deletions

View File

@@ -91,6 +91,11 @@ See <<./http.adoc#http-request-mapping,Request Mapping Support>> and <<./http.ad
When the request body is empty or `payloadExpression` returns `null`, the request params (`MultiValueMap<String, String>`) is used for a `payload` of the target message to process.
Starting with version 5.2, the `WebFluxInboundEndpoint` can be configured with a `Validator`.
It is used to validate elements in the `Publisher` to which a request has been converted by the `HttpMessageReader`.
An invalid payload is rejected with an `IntegrationWebExchangeBindException` (a `WebExchangeBindException` extension), containing all the validation `Errors`.
See more in Spring Framework https://docs.spring.io/spring/docs/current/spring-framework-reference/core.html#validation[Reference Manual] about validation.
[[webflux-outbound]]
=== WebFlux Outbound Components

View File

@@ -97,7 +97,9 @@ See <<./mail.adoc#mail-inbound,Mail-receiving Channel Adapter>> for more informa
==== WebFlux Changes
The `WebFluxRequestExecutingMessageHandler` now supports a `Publisher`, `Resource` and `MultiValueMap` as a request message `payload`.
The `WebFluxInboundEndpoint` now supports a request payload validation.
See <<./webflux.adoc#webflux,WebFlux Support>> for more information.
[[x5.2-mongodb]]
==== MongoDb Changes