Created
February 6, 2021 04:11
-
-
Save KalpaD/d3d593439df05326904bc5a62b232d11 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| @RestController | |
| public class ValidationDemoController { | |
| @PostMapping("/format") | |
| public Mono<ResponseEntity<FormattedNameResponse>> format(@Valid @RequestBody Mono<FormatNameRequest> request) { | |
| return request | |
| .map(res -> ResponseEntity.status(HttpStatus.OK).body(FormattedNameResponseMapper.fromFormatNameRequest(res))) | |
| .onErrorResume(WebExchangeBindException.class, | |
| ex -> Mono.just(ResponseEntity.status(HttpStatus.BAD_REQUEST) | |
| .body(FormattedNameResponseMapper.fromWebExchangeBindException(ex)))); | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment