Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- @Configuration
- public class BookRouter {
- @Bean
- public RouterFunction<ServerResponse> routeBooks(BookHandler bookHandler) {
- return RouterFunctions
- .route(RequestPredicates.GET("/books")
- .and(RequestPredicates.accept(MediaType.APPLICATION_JSON)), bookHandler::getBooks)
- .andRoute(RequestPredicates.GET("/books/{id}")
- .and(RequestPredicates.accept(MediaType.APPLICATION_JSON)), bookHandler::getBook);
- }
- }
- public class BookHandler {
- public Mono<ServerResponse> getBook(ServerRequest request) {
- return ServerResponse
- .ok()
- .hint(Jackson2CodecSupport.JSON_VIEW_HINT, MyJacksonView.class)
- .body(...)
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement