Hi Guys,
Let’s see how we can implement in a @RestController (not @Controller) in a Spring Boot Reactive project. Code is pretty simple.
@RestController @RequestMapping("example") public class XCISStripeZACheckoutController { @RequestMapping(value = "/redirect/", method = RequestMethod.GET, produces = MediaType.TEXT_HTML_VALUE) public Mono<Void> redirect(ServerWebExchange exchange) { ServerHttpResponse response = exchange.mutate().build().getResponse(); response.setStatusCode(HttpStatus.SEE_OTHER); response.getHeaders().setLocation(URI.create("https://www.google.com")); return response.setComplete(); } }
That’s it.
Feedback / comments are welcome.
Have a nice day ahead.
Leave a Reply