February 2019
Intermediate to advanced
442 pages
11h 46m
English
The next part is to define the router and handler for getting the student data. Let's recall that routers are used to route the request as they serve the purpose of @RequestMapping in the annotated controller, while handlers actually process the incoming request, which is similar to the Spring MVC controller handler method. The router class looks as follows:
@Configurationpublic class StudentRouter { @Autowired private StudentHandler studentHandler; @Bean RouterFunction<ServerResponse> returnStudent() { return RouterFunctions.route(RequestPredicates.GET("/api/f/getStudent/{rollNo}"), studentHandler::getStudent); } @Bean RouterFunction<ServerResponse> returnAllStudent() { return RouterFunctions.route(RequestPredicates.GET("/api/f/getAllStudent"), ...