February 2019
Intermediate to advanced
442 pages
11h 46m
English
We have written two different classes for the handler and router; however, we can declare the configuration that covers the functionality of both the router and handler in a single class. This can be done by combining the handler and router method pair in one single method as follows:
@Configurationpublic class StudentRouterHandlerCombined { @Autowired private StudentMongoRepository studentMongoRepository; @Bean RouterFunction<ServerResponse> returnStudentWithCombineFun(){ HandlerFunction<ServerResponse> studentHandler = serverRequest -> { int rollNo = getInt(serverRequest.pathVariable("rollNo")); return ServerResponse.ok(). body(studentMongoRepository.findByRollNo(rollNo) , Student.class); }; RouterFunction<ServerResponse> ...Read now
Unlock full access