This repository demonstrates how you can validate request body of incoming requests in Spring Cloud Gateway.
Body inspecting is implemented in BodyGlobalFilter and example validation logic
is implemented in SampleBodyValidationFilter.
Any use case that requires request validation can be implemented on gateway level - for example perfect candidates are:
You can read more about this code at Alexa Request Validation with Spring Cloud Gateway .
./gradlew build
./gradlew bootRun
In order to play with requests you can run them from requests folder.
Valid request:
POST http://localhost:8080/example/200
Content-Type: application/json
{"fieldToValidate": "secret"}Invalid request:
POST http://localhost:8080/example/200
Content-Type: application/json
{"fieldToValidate": "not valid"}