Skip to content

Instantly share code, notes, and snippets.

@KalpaD
Created February 6, 2021 04:11
Show Gist options
  • Select an option

  • Save KalpaD/d3d593439df05326904bc5a62b232d11 to your computer and use it in GitHub Desktop.

Select an option

Save KalpaD/d3d593439df05326904bc5a62b232d11 to your computer and use it in GitHub Desktop.
@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